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

My Script For My Game Is Broken In The ROBLOX Player, Not The Studio?

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?

1 comment

0

Why do you have a wait at the end? Does absolutely nothing to have a wait there.

1 answer

✓ Accepted answer

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!

1 comment

0

I'll Check Now,

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