I'm trying to make a randomized click giver, but I don't know what I'm doing wrong.
local Weapons = game.ReplicatedStorage.Weapons:GetChildren() function onClick(plyr) script.Parent.ClickDetector.MouseClick:connect(onClick) local Weapon = Weapons[math.random(1,#Weapons)]:Clone() Weapon.Parent = game.Players.LocalPlayer.Backpack end
Thanks if you can help, I'm also a bit of a noob, so please go easy!
So there are a few problems with your script :
Line 5 should be outside the function, otherwise the function won’t connect to the event and the function will never run.
ClickDetectors (I think) can only work with server scripts and not local scripts. On line 8, use “plyr” instead of “game.Players.LocalPlayer”, as LocalPlayer only works in local scripts.
Use “:Connect” instead of “:connect”. They both still work but “:connect” is deprecated, so it’s recommended to use the other one.
That’s all the errors I see in this script so far. If there are any other problems happening still, just comment and I’ll get back to you soon.