Hello!
I made a teleport system, with a button where the player can click on it. Before, its working, like my player can be teleported at the place i want. But with NO reasons, now, my player cant be teleported.
And the print(test2) dont appear in the output too. Its in normal script ( no local script )
local clickDetector = workspace.Button2.Button.ClickDetector
local EndBlock = workspace.pos
clickDetector.MouseClick:Connect(function(touched)
print("test")
if touched.Parent:FindFirstChild("Humanoid") then
print("test2")
local char = touched.Parent
local humanoidRootPart = char.HumanoidRootPart
print(char)
print(humanoidRootPart)
humanoidRootPart.Position = EndBlock.Position
end
end)
local clickDetector = workspace.Button2.Button.ClickDetector
local EndBlock = workspace.pos
clickDetector.MouseClick:Connect(function(touched)
print("test")
if touched.Parent:FindFirstChild("Humanoid") then
print("test2")
local char = touched.Parent
local humanoidRootPart = char.HumanoidRootPart
print(char)
print(humanoidRootPart)
humanoidRootPart.CFrame = EndBlock.CFrame
end
end)
You don’t need to check if it’s a player. A ClickDetector will return the player who pressed the button. So, in this case you code would look something like this:
local clickDetector = game.Workspace.Button2.Button.ClickDetector
local EndBlock = game.Workspace.pos
clickDetector.MouseClick:Connect(function(player)
local char = player.Character
local humanoidRootPart = char.HumanoidRootPart
humanoidRootPart.CFrame = EndBlock.CFrame
end)
You’re kinda a bit too late on that since the issue is already resolved since it was already found out that it was cause of incorrect parameter usage