So I created a simple script that is supposed to teleport the player to a different part once it's touched. The problem is that when another player touches the part it adds to the variable PartSelect of the other player. I only want the variable PartSelect to belong to the local player so when the Part is stepped on by another player its not adding 1 to their variable.
local object = workspace.Part
local debounce = false
local partSelect = 0
local function test(hit)
if hit.Parent:FindFirstChild("Humanoid")then
if debounce == false then
debounce = true
local player = hit.Parent
if partSelect <= 3 then
partSelect = partSelect + 1
end
if partSelect == 4 then
partSelect = 1
end
local part = game.Workspace:FindFirstChild("Part" .. partSelect)
player.HumanoidRootPart.CFrame = CFrame.new(part.Position)
wait(1)
debounce = false
end
end
end
object.Touched:Connect(test)

6 comments
how would I go by re scripting that?
how would I go by re scripting that?
how would I go by re scripting that?
how would I go by re scripting that?
how would I go by re scripting that?
No idea, do some research. I will tell you that it is possible to send values to a server script using RemoteEvents.