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

Making a local debounce per player?

How can I teleport more than one person, but make it where each person has their own local debounce wait() ?

game.Players.PlayerAdded:connect(function(player)
	local bv1 = Instance.new("BoolValue", player)
	bv1 = false
	if game.Players.LocalPlayer:FindFirstChild("BoolValue") == nil then
		local bv = Instance.new("BoolValue", game.Players.LocalPlayer)
		bv = false
	end
	player.CharacterAdded:connect(function(chara)
		chara:WaitForChild("Humanoid").Died:connect(function()
			if chara:FindFirstChild("BoolValue") == nil then
				local bv = Instance.new("BoolValue", chara)
				bv = false
			end
		end)
	end)
end)

teleporter

local part = script.Parent
local Teleporter = part.Teleporter

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') and hit.parent:FindFirstChild("BoolValue") == false then
		local player = hit.Parent
		player.BoolValue = true
		player.HumanoidRootPart.CFrame = CFrame.new(Teleporter.Position)
		wait(2)
		player.BoolValue = false
		
	end
end)



Teleporter.Touched:connect(function(hit)  --Old code but imagine debounce being the BoolValue
	if hit.Parent:FindFirstChild('Humanoid') and debounce == false then
		debounce = true
		wait(1)
		local player = hit1.Parent
		player.HumanoidRootPart.CFrame = CFrame.new(part.Position)
		wait(1.5)
		debounce = false
	end
end)

3 comments

0

can you explain this in more detail. What do you mean by teleport? the teleport service or moving a player in the workepace.

0

A player touches a teleport Part which teleports them to the position of another Part

0

When you make a Value (any value), the name is just "Value". You could change your FindFirstChild's to FindFirstChildOfClass or change where it says "BoolValue@ to just "Value".

1 answer

Insert a BoolValue inside a player. You can change its value to true or false and do your code. Basic set up for a bool value:

game:GetService("Players").PlayerAdded:Connect(function(plr)
    local debounce = Instance.new("BoolValue",plr)
    debounce.Name = "Debounce"
    debounce.Value = false 
end)

2 comments

0

I already did that, but for some reason it didnt work. In the output it would say BoolValue is not a model of Player or whatever.

0

anyways I might just re-do my code over since it's not working

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