Your problem is that there are no arguments in this specific event/function. Therefore, we simply need to get the player a different way. Make sure that this is in a LocalScript, and follow what I do.
##Getting the player
First, we need to simply get the player. To do this, we'll use LocalPlayer. This gets the player from a LocalScript, as long as it's a descendent of the Player, the Backpack, or the PlayerGui. Here's what it will look like:
Player=game.Players.LocalPlayer
So now we have that set. Onto the next part.
##Setting Up The Function
For this part, we simply need to setup the function differently. Here's how it should look:
function Click()
if Character:FindFirstChild("Humanoid") then
local Humanoid=Character.Humanoid
if Humanoid.Health > 0 then
Character.HumanoidRootPart.CFrame=CFrame.new(Vector3.new(TeleportPart.Position))
end
end
end
Btn.MouseButton1Click:connect(Click)
So basically, that's it.
##Final Product
Now, we'll put the entire script together for you:
local Btn = script.Parent
local Gui = Btn.Parent.Parent.Parent
TeleportPart = workspace["4"]
Player=game.Players.LocalPlayer
repeat wait() until Player.Character
Character=Player.Character
function Click()
if Character:FindFirstChild("Humanoid") then
local Humanoid=Character.Humanoid
if Humanoid.Health > 0 then
Character.HumanoidRootPart.CFrame=CFrame.new(Vector3.new(TeleportPart.Position))
end
end
end
Btn.MouseButton1Click:connect(Click)
Anyways, hope I helped, if you have any further questions/problems, please leave a comment below :P
###-Dyler3
1 comment
I'm not so sure if this will help, but on Roblox wiki obby lesson, it shows how to make a teleporter. Check it out.