Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making a local debounce per player?

Asked by
Yozoh 146
6 years ago
Edited 6 years ago

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)

0
can you explain this in more detail. What do you mean by teleport? the teleport service or moving a player in the workepace. User#5423 17 — 6y
0
A player touches a teleport Part which teleports them to the position of another Part Yozoh 146 — 6y
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". User#19524 175 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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)
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. Yozoh 146 — 6y
0
anyways I might just re-do my code over since it's not working Yozoh 146 — 6y
Ad

Answer this question