I have a UI so that when you click it the player will teleport to a part called teleport. However, it doesn’t work and an error always pops up saying:
11:34:15.693 - MouseButton1Click is not a valid member of ScreenGui
Script
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.character.LowerTorso.CFrame = CFrame.new(workspace.teleport.position)
end)
Thanks for reading!
3 Likes
Is the script under a button? Because the error doesn’t say so.
rokec123
(rok)
March 12, 2020, 6:39pm
#3
As the error says, screen guis don’t have .MouseButton1Click event.
Btw make sure to capitalize character oitherwise it’ll error.
1 Like
It’s in StarterGui under ScreenGui
So do I need to put the script in the botton?
your trying to define an event that cant be used in a ScreenGui.
add a GuiButton of some kind(like ImageButton
or TextButton
) inside the ScreenGui and transfer the script into the GuiButton.
I use this:
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
plr.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(workspace.Teleport.CFrame)
end)
1 Like