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

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

Asked by 6 years ago

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?

0
Why do you have a wait at the end? Does absolutely nothing to have a wait there. hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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!

0
I'll Check Now, arondevs 65 — 6y
Ad

Answer this question