code:
1 | function onClicked() |
2 | game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(Vector 3. new( 26.2 , - 10.855 , 319.8 )) |
3 | game.Workspace.Sounds.DinkSecretRoom:Play() |
4 | end |
5 |
6 |
7 |
8 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
THIS IS IN A NORMAL SCRIPT, IF ITS IN A LOCALSCRIPT IT BREAKS. PLEASE HELP ME. I NEED TO CALL A LOCALPLAYER BUT WITHOUT LOCALPLAYER. SORRY FOR CAPS I WAS TO LAZY TO TYPE AGAIN.
While LocalPlayer
can only be accessed through a Local Script, in your case, you could simply use the Player value of the ClickDetector
object. Here's a better version of your code:
1 | function onClicked(player) |
2 | player.Character.HumanoidRootPart.CFrame = CFrame.new( 26.2 , - 10.855 , 319.8 ) |
3 | game.Workspace.Sounds.DinkSecretRoom:Play() |
4 | end |
5 |
6 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
Also do note that CFrame.new doesn't require Vector3.new to be inside it.