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

Why Is my present script not giving the hat to the player, Instead breaking It?

Asked by 2 years ago

So I am making a present block where If you touch Is you either get something good like a hat or a little speed boost or something bad like being killed when you touch It or It explodes, so the first reward Is a hat that will attach Itself to the person who touches the present but here Is the problem

****The Problem The problem Is where If you try touching the present the hat will not appear on your head Infact, doesn't position where the hat should be, the decal for the hat doesn't appear, the size I set doesn't want to be size and I think the broken hat Is collatable (Even though I don't want It to)

Script:

script.Parent.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
        local Reward = math.random(1,1)

        if Reward == 1 then
            local CoolHat = Instance.new("Part")
            local CoolHatFace = Instance.new("Decal")

            CoolHat.Parent = humanoid.Parent.Head
            CoolHat.Position = humanoid.Parent.Head
            CoolHat.Orientation = humanoid.Parent.Head
            CoolHat.Size = Vector3.new(1.24, 1.278, 1.312)
            CoolHat.BrickColor = BrickColor.Yellow()
            CoolHat.CanCollide = false
            CoolHatFace.Parent = CoolHat
            CoolHatFace.Texture = "rbxassetid://9629084283"
            wait(0.1)
            script.Parent:Destroy()
        end
    end
end)

Answer this question