modifique esse scipt que ao inves de clonar um acessorio, clone um meshpart com um…
- User
modifique esse scipt que ao inves de clonar um acessorio, clone um meshpart com um Motor6D dentro dele dentro da RightHand do jogador , a defina o Part1 do motor6d A essa RightHand do player : local ReplicatedStorage = game:GetService("ReplicatedStorage") local AccessoryEvent = ReplicatedStorage:WaitForChild("AccessoryEvent") local Players = game:GetService("Players") local ServerStorage = game:GetService("ServerStorage")
local AccessoriesFolder = ServerStorage:WaitForChild("Accessories") local accessoryTemplate = AccessoriesFolder:WaitForChild("Giz")
local playerData = {} -- Table to store per-player data
-- Function to equip accessory to player local function equipAccessory(player) local character = player.Character if character then local accessoryClone = accessoryTemplate:Clone() accessoryClone.Parent = character return accessoryClone end return nil end
-- Function to handle typing events from the client local function onAccessoryEvent(player, action) if action == "Typing" then local data = playerData[player] or {} playerData[player] = data
data.lastTypingTime = tick() if not data.accessory then data.accessory = equipAccessory(player) data.isAccessoryEquipped = true end -- Start timer coroutine if not already running if not data.timerCoroutineRunning then data.timerCoroutineRunning = true coroutine.wrap(function() while data.isAccessoryEquipped do local timeSinceLastTyping = tick() - data.lastTypingTime if timeSinceLastTyping >= 5 then -- Remove accessory if data.accessory and data.accessory.Parent then data.accessory:Destroy() end data.accessory = nil data.isAccessoryEquipped = false data.timerCoroutineRunning = false break else -- Wait for the remaining time wait(5 - timeSinceLastTyping) end end end)() end endend
-- Connect the event AccessoryEvent.OnServerEvent:Connect(onAccessoryEvent)
-- Clean up when players leave Players.PlayerRemoving:Connect(function(player) local data = playerData[player] if data then -- Clean up accessory if data.accessory and data.accessory.Parent then data.accessory:Destroy() end playerData[player] = nil end end)
- Assistant