this is the script:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local checkpoint = game.Workspace.Checkpoints:WaitForChild("Checkpoint1")
local debounce = false
local dead = game.ReplicatedStorage:WaitForChild("DiedEvent")
local ball = game.ReplicatedStorage:WaitForChild("BallEvent")
local TextButton = script.Parent
TextButton.Activated:Connect(function()
if not debounce then
debounce = true
local rootPart = player.Character.HumanoidRootPart
local Character = player.Character or player.CharacterAdded:Wait()
rootPart.CFrame = checkpoint.CFrame * CFrame.new(0,1,0)
ball:FireServer()
dead:FireServer(player.Name)
debounce = false
end
end)
it teleports me but it dosn’t fire the ball event for the first time, but it works after the second time and other for some reason, here’s the ball script:
local event = game.ReplicatedStorage:WaitForChild("BallEvent")
event.OnServerEvent:Connect(function(plr)
wait(0.1)
local char = plr.Character
local boulder = game.ReplicatedStorage:WaitForChild("Boulder"):Clone()
boulder.Parent = workspace.Balls
boulder.Position = char.HumanoidRootPart.Position + char.HumanoidRootPart.CFrame.LookVector * 10
boulder.Plr.Value = char.Name
end)
1 Like
i think you forgot to add a player argument in the first script for the ball event
the ball event dosn’t require a player arguement, it works the second time and no errors pops up
It shouldnt require a player argument since its from Client → Server.
What does the dead event do? charssssss
its a script every ball has inside, checks if the player’s name is equal the string value stored inside the ball
local event = game.ReplicatedStorage:WaitForChild("DiedEvent")
event.OnServerEvent:Connect(function(plr,name)
if name == script.Parent.Plr.Value then
script.Parent:Destroy()
end
end)
Do you get any infinite yield warnings?
nope, no errors whatsoever at all
Remove the wait(0.1) on the other script and add wait(0.1) before the “if name == script.Parent.Plr.Value then”
Because you are searching the name of something before the name changes.
nope, still dosn’t work the first time, but works the second
print something at the beginning of the event, see if it prints the first time activating the button.
If it prints first try, keep moving the print a line down until it doesn’t.
i put print yes on both the end of the code like this:
local event = game.ReplicatedStorage:WaitForChild("BallEvent")
event.OnServerEvent:Connect(function(plr)
local char = plr.Character
local boulder = game.ReplicatedStorage:WaitForChild("Boulder"):Clone()
boulder.Parent = workspace.Balls
boulder.Position = char.HumanoidRootPart.Position + char.HumanoidRootPart.CFrame.LookVector * 10
boulder.Plr.Value = char.Name
print("yes")
end)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local checkpoint = game.Workspace.Checkpoints:WaitForChild("Checkpoint1")
local debounce = false
local dead = game.ReplicatedStorage:WaitForChild("DiedEvent")
local ball = game.ReplicatedStorage:WaitForChild("BallEvent")
local TextButton = script.Parent
TextButton.Activated:Connect(function()
if not debounce then
debounce = true
local rootPart = player.Character.HumanoidRootPart
local Character = player.Character or player.CharacterAdded:Wait()
rootPart.CFrame = checkpoint.CFrame * CFrame.new(0,1,0)
dead:FireServer(player.Name)
ball:FireServer()
print("yes")
debounce = false
end
end)
ignore the infinite yield its another script
Ok.
At the start of the game, the player is on a total different position?
See if on the first time the ball spawns on the position before teleporting.
btw it did the same thing, roblox format broke it. is really hard to explain so here’s the game:
when you click on the down right thing it should pop up a tp menu
Yes, I was right, the ball is spawning in the position before teleporting.
Try spawning it when the Character Spawns, using CharacterAdded and then connecting the ball event.
Tell me if it works.
the character dosn’t respawn, i am merely trigger the event after the player teleports
Oh true, then make a longer wait, like 0.5
the teleporting or the event? if the event do i delay the death event too or no