The reason why that is happening is because you are creating the “cannon.Triggered” event for every player that joins which causes the code to run for all the players. To fix this, you can have one event that handles the “cannon.Triggered” event and get the player who triggered it from the “Triggered” argument:
local cannon = script.Parent.ProximityPrompt
local touched = false
local Players = game:GetService("Players")
local Sound = script.Parent.CannonSound
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
print(Character.Name)
--Do stuff you want to happen when a player's character is added
end)
end)
cannon.Triggered:Connect(function(Triggered)
local Character = Triggered.Character
local HumanoidRootPart = Character and Character:FindFirstChild("HumanoidRootPart")
if not HumanoidRootPart then return end
HumanoidRootPart.CFrame = script.Parent.Parent.Tele.CFrame
touched = true
cannon.Enabled = false
wait(0.5)
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Velocity = Vector3.new(0,200,150)
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.P = math.huge
bodyVelocity.Parent = HumanoidRootPart
Sound:Play()
task.wait(1)
touched = false
bodyVelocity:Destroy()
task.wait(5)
cannon.Enabled = true
end)