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

Change string value with script not working?

So I have a script located on a image button that is on a frame and that frame in a screen gui but the script throws me an error (Read Below)

Script:

local plr = game.Players.LocalPlayer
local kat = plr:WaitForChild("EquippedKat")
local button = script.Parent

button.MouseButton1Click:Connect(function()
	kat.Value = button.Name
end)

Error:

19:35:41.450 - Players.0Papa_Rat0.PlayerGui.Shop.Grid.Classic.Script:3: attempt to index nil with 'WaitForChild'

2 answers

✓ Accepted answer

You are using a Server-Script!

You have to use a LocalScript for that cuz you cant get the LocalPlayer with a server script!

I hope that helped you :D

1 comment

0

Thanks

Hi 0Papa_Rat0,

This is probably because you are using a Server Script. Use a LocalScript and it will be able to get the players.

Go here to find out more about LocalScripts.

Thanks,

Best regards,

IdealistDeveloper,

1 comment

0

Thanks too

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