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

Trying to make a money giver that gives you money once and disappears for good!?

I've been working on a tycoon and I needed a money giver kinda as a reward so once you bought let's say a bench for your tycoon a money giver would pop up with it giving you money once then disappear. So I attempted making one and it worked but when I left the tycoon and joined the money giver came back and the game is supposed to save is there anything I can add to the scripts to make the money only work once and it remembers that here are the scripts.

deb = false
script.Parent.Touched:connect(function(part)
	if game.Players:FindFirstChild(part.Parent.Name) then
		if deb == false then
			deb = true
			local plr = game.ServerStorage.PlayerMoney:FindFirstChild(part.Parent.Name)
			script.Parent.BrickColor = BrickColor.new("Bright red")
			plr.Value = plr.Value + script.Parent.Parent.Amount.Value
			wait(script.Parent.Parent.TimeToWait.Value)
			deb = false
			script.Parent.BrickColor = BrickColor.new("Bright green")
			script.Parent:Remove()
		end
	end
end)
enabled = 0
val = 0

function onTouched(part)
-- All characters have a Humanoid object
-- If the model has one, it is a character
-- print("In The Script")
 local h = part.Parent:findFirstChild("Humanoid") -- Find Humanoids in whatever touched this
 if (h ~=nil) then -- If there is a Humanoid then
       -- h.Health = h.MaxHealth -- Set the health to maximum (full healing)
if (enabled == 0) then
enabled = 1
wait(0.5)
			script.Parent.Transparency = 1
			script.Parent.CanCollide = false
    script.Parent:Remove()
end
 end
 end

script.Parent.Touched:connect(onTouched) -- Make it call onTouched when touched


2 answers

You can make a bool value stating true or false that the player has already received the gift. You would then save it in a datastore so the game recognizes if the player has already gotten the prize before.

4 comments

0

btw sorry for my messy english im tired

0

lol its ok thanks for the help but i would have no idea how to do that

0

search online on how to do datastores, AlvinBlox is a great guy for that

0

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