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

Change string value with script not working?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by 4 years ago

You are using a Server-Script!

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

I hope that helped you :D

0
Thanks 0Papa_Rat0 63 — 4y
Ad
Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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,

0
Thanks too 0Papa_Rat0 63 — 4y

Answer this question