Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make Gui not pay anymore cash to tp, even when on rejoin?

this is the script the script parent has a IntValue called "Cost" the value is 500 the LocalScript 2 is:

script.Parent.MouseButton1Click:Connect(function(player)
	game.Players.LocalPlayer.PlayerGui.ropelength.Frame.Visible = false
	game.Workspace.Teleport.RemoteFunction:InvokeServer()
	game.Players.LocalPlayer.Character.Rope:Destroy()
end)

this is the original script. Name: LocalScript

local player = game.Players.LocalPlayer
local Cash = player.leaderstats.Money
local price = script.Parent.Cost.Value

script.Parent.MouseButton1Click:Connect(function(player)
	if Cash.Value >= 500 then
		local clone = script.Parent.Parent.yyyy.LocalScript2:Clone()
		Cash.Value = price - 500
		game.Players.LocalPlayer.PlayerGui.ropelength.Frame.Visible = false
		game.Workspace.Teleport.RemoteFunction:InvokeServer()
		script.Parent.BackgroundColor3 = Color3.new(1 ,1, 1)
		clone.Parent = script.Parent
		script.Parent.Parent.yyyy.LocalScript2:Destroy()
		script:Destroy()
		game.Players.LocalPlayer.Character.Rope:Destroy()
	end
end)

1 answer

You know since this is a localscript any modifcation you to Cash does only change for this player, the other players wont see these changes, next deleting/enalbing/disabling/cloning scripts is a bad practice. And the solution to your problem is Datastores. Data stores are a storage feature for Roblox games. They can be used to save data which should persist between game sessions. So what you need to do is check if the player is already in the datstore if it isnt then you give him the money and set the player in the datastore so the next time you he joins the game will see he is in the datastore and he wont get the money again

1 comment

0

ty i will try

This discussion is preserved as it was. New answers, comments, and votes are closed.