Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont this button give this gamer hat when I click it?

I made this script that I thought should give me a hat when I click it but it hasn't worked. what could be my mistake?

local button = script.Parent
local player = game.Players

button.MouseButton1Up:Connect(function()
	local hat = game.ReplicatedStorage.BlackTacticalHeadphones:Clone()
	hat.Parent = player
	
	
end)

3 comments

0

Where is this script in and is it a serverscript or a localscript

0

its in the button. Its a local script

0

if its a local script then that might be your problem, if something is affecting the server such as creating a new instance or cloning something then that would be used with a script not a local one, so you would have to put a remote event on the local script to make a item

1 answer

Ok. So. There are a few errors. Your parenting it to the PLAYER. Not the character You're not setting the position of the hat. So it will either be really far away or it will be INSIDE of your head. You parenting it to game.Players?? This is the script you wanna use

local button = script.Parent

button.MouseButton1Up:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
	    local character = hit.Parent
	    local player = game.Players:GetPlayerFromCharacter(character)
	    local hat = game.ReplicatedStorage.BlackTacticalHeadphones:Clone()
	    hat.Parent = character:FindFirstChild("Head"):FindFirstChild("HatAttachment")
	end
end)

Tell me if that works. I didnt write it in studio

Also make sure you have the BlackTacticalHeadphones in your ReplicatedStorage

1 comment

0

not work

This discussion is preserved as it was. New answers, comments, and votes are closed.