I have been trying to fix my tool that gives cash when u click it. But it doesnt work still, as an example, from my sight i see i have 100K moistbux and from others sight it says 0, heres my tool script, please answer if you can help me
local tool = script.Parent reb = game.Players.LocalPlayer.leaderstats.moistbirths function onActivation() game.Players.LocalPlayer.leaderstats.moistbux.Value = game.Players.LocalPlayer.leaderstats.moistbux.Value + 10e21 * reb.Value wait(0) end tool.Activated:connect(onActivation)
LocalScript
. It only runs on the client. Because of the new update that removed Experimental Mode, thus forcing FE, you'll need remote events and remote functions.-- Server script, inside ServerScriptService local ReplicatedStorage = game:GetService("ReplicatedStorage") local GiveMoney = ReplicatedStorage:WaitForChild("GiveMoney")-- RemoteEvent GiveMoney.OnServerEvent:Connect(function(player) player.leaderstats.moistbux.Value = player.leaderstats.moistbux.Value + 10e21 * (player.leaderstats.moistbirths.Value) end)
local ReplicatedStorage = game:GetService("ReplicatedStorage") local GiveMoney = ReplicatedStorage:WaitForChild("GiveMoney") local tool = script.Parent function onActivation() GiveMoney:FireServer() -- get money wait() end tool.Activated:Connect(onActivation) -- switch to :Connect, :connect is deprecated
Add a RemoteEvent
in ReplicatedStorage
Call it "MoistBuxEvent"
Add a LocalScript
in the tool
In the localscript:
local gimmemoistbux = game.ReplicatedStorage.MoistBuxEvent function onActivation() gimmemoistbux:FireServer() -- everyone sees it after this end tool.Activated:Connect() -- "connect" is deprecated, recommended using "Connect"
In the serverscript:
-- exact same code but its fixed for FE local gimmeitnow = game.ReplicatedStorage.gimmemoistbux gimmeitnow.OnServerEvent:Connect(function(player) reb = player.leaderstats.moistbirths player.leaderstats.moistbux.Value = player.leaderstats.moistbux.Value + 10e21 * reb.Value wait(0) end
Took me like 10 mins to write this lol.
Put in a local script in tool,
local tool = script.Parent local player = game:GetService("Players") local leaderstats = player:WaitForChild("leaderstats") local bux = leaderstats:WaitForChild("moistbux") local reb = leaderstats:WaitForChild("moistbirths") function onActivation() bux.Value = bux.Value + 10e21 * reb.Value wait(0.1) end tool.Activated:Connect(onActivation)