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

Making a script work locally? I accept answers.

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)

1 answer

Make the PartSelect script in a separate local script and have it fire a remote event to the main script.

6 comments

0

how would I go by re scripting that?

0

how would I go by re scripting that?

0

how would I go by re scripting that?

0

how would I go by re scripting that?

0

how would I go by re scripting that?

0

No idea, do some research. I will tell you that it is possible to send values to a server script using RemoteEvents.

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