I’m guessing you are using a touched event, right? If so, use a debounce:
local debounce = true
--Call the function (ie. script.Parent.Touched:Connect(function(hit)
if debounce then
debounce = false
--rest of script
task.wait(1)
debounce = true
end
end) --close the connected function
I looked at your output and I am almost certain the problem is that you sre not disconnecting your event.
If you are using an event INSIDE another event make sure you disconnect the event after you have done with it or else you eill have multiple connections cennected to the same event.
Could we see the scripts as well as the nested events
local GetCharacter = game:GetService("ReplicatedStorage").RemoteEvents:WaitForChild("GetCharacter")
local function Teleport(player, position)
GetCharacter.OnServerEvent:Connect(function(character)
print(character)
end)
GetCharacter:FireClient(player)
end
workspace.HJ.PPPart.Attachment.ProximityPrompt.Triggered:Connect(function(p)
Teleport(p, Vector3.new()) -- this is test
end)
StarterPlayerScripts:
local GetCharacter = game:GetService("ReplicatedStorage").RemoteEvents:WaitForChild("GetCharacter")
GetCharacter.OnClientEvent:Connect(function()
local character = game:GetService("Players").LocalPlayer.Character
GetCharacter:FireServer(character)
end)
As I suspected, you have a OnServerEvent insid the Proximity.Triggred event.
The structure of the code is the problem. There are a few things to mention too.
local GetCharacter = game:GetService("ReplicatedStorage").RemoteEvents:WaitForChild("GetCharacter")
GetCharacter.OnClientEvent:Connect(function()
local character = game:GetService("Players").LocalPlayer.Character
GetCharacter:FireServer(character)
end)
This is pointless as getting the character can be done on the server.
This will bring up a security issue as the client can send whatver they want.
You should have used a Remote function for two way communication.
Now if you want to teleport the player it is as easy as this.
-- ServerScript
local Triggered(Player: Player)
local Character = Player.Character -- Character should always exist if the player is using proximity prompt
local Humanoid = Character:FindFirstChild("Humanoid")
if not Humanoid or Humanoid.Health < 1 then return end
Character:SetPrimaryPartCFrame(CFrame.new(TELEPORT_POSITION))-- His is the runcion you can use to teleport a character.
end
ProximityPrompt.Triggered:Connect(Triggered)
Thre is no need for cross device communication in this case. it can and should be done on the server.
Also disconnect your vnts after you have finished using them in the future. Not disconnecting events will cause lag if you have a lot of them and you will run into bugs like that one.