I created this lengthy (and quite messy) LOCAL script for a shuttle craft. It makes a sound to simulate takeoff, and changes a decal in front of the window every so often to show it's moving. Then it grabs another shuttle from ReplicatedStorage and teleports you to a brick at the new shuttle. I tried putting it in a regular script, to find that this only works in studio. Here is the code:

repeat wait() until game.Players.LocalPlayer
char = game.Players.LocalPlayer.Character
destination = game.Workspace.planshut

function onClick()
	script.Parent.Sound:Play()
	wait(6)
	script.Parent.Parent.view.Transparency = 0 -- view space
	wait(1)
	script.Parent.Parent.view.Decal.Transparency = 0
	script.Parent.Parent.view.Decal.Texture = "http://www.roblox.com/asset?id=244339877" --view planet
	wait(1)
	script.Parent.Parent.view.Decal.Texture = "http://www.roblox.com/asset?id=244339507" -- closer view
	wait(1)
	script.Parent.Parent.view.Decal.Texture = "http://www.roblox.com/asset?id=244339544" -- surface view
	wait(1)
	local s = game.ReplicatedStorage.planetshut:clone()
	s.Parent = game.Workspace -- make shuttle on planet
	if script.Parent.Parent.Door.Transparency == 0 then
		s.Door.Transparency = 0
		s.Door.CanCollide = true
	else
		s.Door.Transparency = 1
		s.Door.CanCollide = false
	end --if door is open, open door on planet shuttle
	char.Torso.Anchored = true
	char.Torso.CFrame = destination.CFrame + Vector3.new(0,4,0)
	wait(0.2)
	char.Torso.Anchored = false --teleport player to planet shuttle
	script.Parent.Parent:Destroy() --destroy this shuttle
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

I can't work out what is wrong! It won't do anything, the output won't tell me anything at all either. Help?

9 comments

0

Before the first line try putting: repeat wait() until game.Players.LocalPlayer

1

A LocalScript can NOT communicate with the ServerStorage, use the ReplicatedStorage instead.

0

It just does nothing, still.

1

The LocalPlayer Never works on a regular script.

0

But why doesn't it work on a LocalScript either?

1

The ServerStorage is a holder for objects on the Server. So, this can only be used by the server, local scripts will not work. ServerStorage is so the Client cannot interact with it(That's what local scripts do), so ReplicatedStorage is workable for Clients AND Server, local script will work!

0

But it DOESN'T.

0

There's no use waiting for the player to exist, it always will. It may be necessary to wait for the character to exist, though. But, you can use this in a server script just by using the built in Player parameter that MouseClick events have. Remember that LocalScripts ONLY RUN inside PlayerGui or Backpack, so you'd probably want to use a server script anyway.

0

Post an answer saying how to do this?