I Am Currently Making A Clicker Game. (I feel embarrassed saying that) But, the script im using to click works perfectly in studio, but malfunctions in the actual roblox player? Here's the script :
plr = script.Parent.Parent.Parent.Parent script.Parent.MouseButton1Click:connect(function() plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 1 wait() end)
I'm really bad at scripting right now, im a beginner soo... Hoping somebody could help me out?
First off, use LocalPlayer
instead of script.Parent.Parent.Parent.Parent
assuming this is in a LocalScript
in the StarterGui
. Second, the wait()
is kind of useless. Third, connect
is deprecated.
local player = game.Players.LocalPlayer local stat = player:WaitForChild("leaderstats").Cash script.Parent.MouseButton1Click:Connect(function() stat.Value = stat.Value + 1 end)
This should work for you. Please accept my answer if this helped!