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

mah.random not working with clickdetector?

Asked by
hokyboy 270 Moderation Voter
5 years ago

-- in servergui local clickdetector = game.Workspace.Chest_n_1.ClickDetector clickdetector.MouseClick:Connect(function() game.Workspace.MyClickDetectorEvent:FireServer() end)

-- in remote event game.Workspace.MyClickDetectorEvent.OnServerEvent:Connect(function()
Cash = math.random(1,3) if Cash ==1 then game.Players.LocalPlayer.leaderstats.Cash = game.Players.LocalPlayer.leaderstats.Cash + 101 end

if Cash==2 then
    game.Players.LocalPlayer.leaderstats.Cash = game.Players.LocalPlayer.leaderstats.Cash + 190
    end



if Cash==3 then
    game.Players.LocalPlayer.leaderstats.Cash = game.Players.LocalPlayer.leaderstats.Cash + 310
end

end)

0
Can't use LocalPlayer on the server. Also use code blocks please. User#19524 175 — 5y
0
Also put your RemoteEvents in Replicated Storage seith14 206 — 5y
0
You can place RemoteEvents somewhere that Server-sided and Client-sided scripts can access. ReplicatedStorage is one of them, and it's easy to locate. User#17685 0 — 5y

Answer this question