Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I fix this code to give the player a hat?

Asked by 3 years ago

Hello! The script I have is supposed to put a hat on the player but for some reason whenever I touch it, it teleports the player to the hairs position (The hair is in replicated storage) and the player gets stuck in that position. Does anyone know how to fix this? It is possible that the script is just outdated. Thanks in advance!

debounce = false



script.Parent.Touched:connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") then -- I use FIndFirstChild() to prevent Errors
        wait(0.5)
        if debounce == false then debounce = true
            local Copy = game.ReplicatedStorage:FindFirstChild("Hair1"):Clone()
            local Char = Hit.Parent -- This is the Character(Model that holds all parts)
            local player = game.Players:GetPlayerFromCharacter(Char) -- So we know WHO to give the Hat
            Copy.Parent = player.Character
            wait(3)
            debounce = false
        end
    end
end)
0
unanchored hair1 lehoaiquoc248 23 — 3y
0
This is because the hat is anchored make sure the hat isnt anchored BuildAboatTest124 51 — 3y

Answer this question