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

Will this work??

I have a script, that requires sufficient credit in order to pass through a door. But it should only charge once:

script.Parent.Touched:connect(function(player) --Door gets touched
	humanoid = player.Parent:FindFirstChild("Humanoid") --If it's the player that touched the door
	if humanoid ~= nil then
		person = game.Players:FindFirstChild(player.Parent.Name)
		touched = script.Parent:FindFirstChild(player.Parent.Name)
		if person ~= nil  and  touched == nil then
			person.leaderstats.Admins.Value = person.leaderstats.Admins.Value - 1 --Decreases the credits
			a = Instance.new("StringValue", script.Parent)
			a.Name = player.Parent.Name
			script.Parent.CanCollide = false
			wait(2)
			script.Parent.CanCollide = true
		elseif touched ~= nil then
			script.Parent.CanCollide = false
			wait(2)
			script.Parent.CanCollide = true
		else humanoid.Health = 0 
		end
	end
end

1 comment

0

Just test it in game, if it doesn't work, use F9 and look at server console (Output)

1 answer

i would use a table to store the people who already paid, or whatever, and after they go through the door, their name or userId is put inside the table so they can never use the door again, if thats what your asking.

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