Cloning A Model from Replicated Storage to Workspace not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I’m trying to make a model move from ReplicatedStorage to Workspace.

  1. What is the issue? Include screenshots / videos if possible!

For some weird reason it says that Line 5 is the problem in my output.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = game.Players.LocalPlayer

local ShipValue = player:WaitForChild("SpaceShipValue") --Line 5


ShipValue.Changed:Connect(function() -- Fires whenever the time value in workspace changes
	if ShipValue.Value == 1 then
		local Clone = ReplicatedStorage.Spaceship:Clone() -- Clones the map from replicated storage
		Clone.Parent = game.Workspace -- Places the cloned map in workspace
	end
end)
2 Likes

What is the error in the output?

1 Like

It says “Script ‘ServerScriptService.Clone’, Line 5 - Studio - Clone:5”

2 Likes

I’ve tried it and it works perfectly. This might be an error with changing the ShipValue. You’ve stated that it fires when the time value in workspace changes, but you defined the ShipValue’s location inside the player.

1 Like

Oh! So would I just put the value in workspace instead and not inside the player?

1 Like

If that’s what your trying to achieve yes. If the ShipValue is located in workspace and not the player then it will give an error because you defined it inside the player. Also make sure that the value actually changes for the event to fire and that the value meets your conditions == 1.

1 Like

Okay well. I put the value inside the player, and it still says that line 5 isn’t working. It’s not in the workspace and it’s in the player this time. I have tried so many things to fix it and it keeps telling me that Line 5 is always the problem.

1 Like

Can you run the game and send a screenshot of player directory, it’s probably because of the value.

1 Like

Is this a local script or a normal script? The error said that the script was in ServerScriptService, you cannot use LocalPlayer in server scripts.

2 Likes

Are you running this code inside of a ServerScript? Because if you are, you cannot access game.Players.LocalPlayer from a ServerScript as you can only access it on the client, not the server.

EDIT: I did not read the post above me, sorry if this looks like a repost.

2 Likes

Yeah I figured out that you can’t use local player in server scripts. I put it in a local script instead in StarterGui.

2 Likes