Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The Script works in studio but not in-game? Possible fix?

Is there a possible fix for this? I don't understand why this is not working :/ It works in studio but not in game...

ScreenGui > TextButton > LocalScript

LocalScript Below.

Character = game.Players.LocalPlayer.Character
torso = Character.Torso

function onClicked(ScreenGui)
	torso.CFrame = CFrame.new(Vector3.new(-131.7, 9.3, -30.85)) -- Coordinates
end

script.Parent.MouseButton1Click:Connect(onClicked)

4 comments

0

Thanks I'll take a look

0

In the past, when I tried to change the position of the player in a local script the server still saw the player in his original location. It was quit strange.

1 answer

✓ Accepted answer

Make your variables local and use WaitForChild() on your Torso.

local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:wait()
local torso = Character:WaitForChild("Torso")
function onClicked()
    torso.CFrame = CFrame.new(-131.7, 9.3, -30.85) -- Coordinates
end

script.Parent.MouseButton1Click:Connect(onClicked)

This discussion is preserved as it was. New answers, comments, and votes are closed.