I'm wanting to this script to give 100,000 dollars if a player clicks the GUI, I'm using Zed's Tycoon Kit, and I was wanting to make a Mod Menu sort of script, Why won't this give money to a player?
local plrm = game.ServerStorage.PlayerMoney local plr = game.Players.LocalPlayer script.Parent.MouseButton1Down:Connect(function() plrm.plr.Value = plrm.plr.Value + 100000 end)
Thank you - eizaray1234
the RemoteEvent as the above comment has mention would be added into your script as seen below
LOCAL SCRIPT
local plrm = game.ServerStorage.PlayerMoney local plr = game.Players.LocalPlayer script.Parent.MouseButton1Down:Connect(function() game.ReplicatedStorage.RemoteEvent:FireServer() -- added the RemoteEvent to the local script plrm.plr.Value = plrm.plr.Value + 100000 end)
then you'd make your server script with the opposite end of the RemoteEvent that will fire when thisRemoteEvent is activated
SERVER SCRIPT
local myName = "PlayerMoney" game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr) local plrm = game.ServerStorage:FindFirstChild(myName) plrm.plr.Value = plrm.plr.Value + 100000 end)
Dont forget to add the RemoteEvent to the replicatedStorage. If you rename the RemoteEvent something else make sure that you name in the in both your scripts.
Personally i've never grabbed a value out of serverstorage this way but it should work none the less, let me know, Thanks!
Hey there!
I’ve never used this tycoon kit before but I would assume your issue is that your changes aren’t replicating to the server and that the client can not access ServerStorage. To fix this, you would use a Remote Event or Remote Function.
Here’s how you would do it...
Local Script
local event = game.ReplicatedStorage.RemoteEvent script.Parent.MouseButton1Down:Connect (function() event:FireServer(100000) end)
Server Script (put this in ServerScriptService)
local event = game.ReplicatedStorage.RemoteEvent local plrm = game.ServerStorage.PlayerMoney event.OnServerEvent:Connect (function(plr, amount) plrm[plr.Name].Value = plrm[plr.Name].Value + amount end)
Note: you’ll need to insert a RemoteEvent into ReplicatedStorage
If this didn’t help, feel free to comment with any questions regarding your issue.
If this helped, please accept and upvote this answer.