Hello, I’m creating exchange GUI, but i don’t know how to transfer Local Script to Script.
local plr = game.Players.LocalPlayer
local id = 23713633
local cash
-- Pet Multiplier
function getMultiplier(Player, Multiplier2)
local Multi = 0
for i,v in pairs(Player.Pets:GetChildren()) do
if v.Equipped.Value == true then
Multi = Multi + v[Multiplier2].Value
end
end
return Multi
end
-- Exchange Gui
script.Parent.Cash.FocusLost:Connect(function(input)
cash = tonumber(script.Parent.Cash.Text)
if cash then
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then
script.Parent.Gems.Text = cash / 50 * 2 * getMultiplier(plr, "Multiplier2")
else
script.Parent.Gems.Text = cash / 50 * 1 * getMultiplier(plr, "Multiplier2")
end
end
end)
script.Parent.Done.MouseButton1Click:Connect(function()
if plr.leaderstats.Cash.Value >= cash then
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - cash
plr.leaderstats.Gems.Value = plr.leaderstats.Gems.Value + script.Parent.Gems.Text
end
end)
When I’m clicking Done Button then I get Gems and I lost Cash but when I leave, Gems and Cash don’t saves beacuse this is Local Script and I don’t know how can I change this to Server Script
You are confused. I think you want to save data after you leave, and the fact that you can’t set values like that on the client as the server and other players won’t see the changes. Local Script runs on the client for the client only and can communicate with the server only with remote events and remote functions.
Data stores are used for saving data even after a player has left and for across server data storage.
Remote Events can allow client to server and server to client communication.
Whose help did you need? Who did help you the most? Pick the one that helped the most and press the solution box so others see this post has been solved. Also because we out there for those juicy solutions!
Keep in mind having a remote that adds money is a wide-open door for exploiters, since they can just send a fake remote. Maybe move this to the server, or, if you can’t, do checks on the server.
Only insecure remotes are really that dangerous, as long as they’re secured properly and don’t carry information the server should handle in the first place, they should be fine.