local ToolName = "FlashLight" while true do game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) if Player.Backpack:FindFirstChild(ToolName) then workspace.BARRIER.Position = Vector3.new(20, 0.5, 45.32) else workspace.BARRIER.Position = Vector3.new(9.63, 0.5, 45.32) end wait(1) end end) end)
Error-- ServerScriptService.Script:13: Expected ')' (to close '(' at line 5), got 'end' - Studio - Script:13
You're missing a few ends in your code. Also, add a wait after or between the loop, so you don't crash. This is the corrected version:
local ToolName = "FlashLight" while true do wait(2)-- change the amount of secs you want it to wait game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) if Player.Backpack:FindFirstChild(ToolName) then workspace.BARRIER.Position = Vector3.new(20, 0.5, 45.32) else workspace.BARRIER.Position = Vector3.new(9.63, 0.5, 45.32 end end) end) end
(Edit: - The other wait between the if statement is redundant, consider removing it!)