Help my key script isn't working

Ello! So this is the idea or what I wanted it’s that when a player finds a key and he gets the key I already figured that out BUT I want it so that whenever the key touches a trigger part a person named Jack to appear in a different way READ THIS PART I figured out how to make it in a normal script for the server but I don’t want that to happen in the server I want this to happen in a client with a local script so I put it in starterplayerscripts that it was already

easy explanation
Player clicks key and gets key, then he takes that key and and the key touches an invisible brick, then the brick makes a person named “Jack” appear and it’s I want it in a local script for the client not server.

the script:
script

local player = game.Players.LocalPlayer

local KeyBoy = game.Workspace.Dresser2.Drawer.Key

local Jack = game.Workspace.Jack

local Jack2 = game.ServerStorage.Jack2

local TriggerTheThing = Jack.ClickPart

TriggerTheThing.Touched:Connect(function(hit)

if hit.Parent.Name == KeyBoy.Name then

print(“touched”)

Jack:Destroy()

Jack2:Clone()

Jack2.Parent = game.Workspace

end

end)

1 Like

Instances kept in ServerStorage and ServerScriptService are not replicated to the client. Use ReplicatedStorage instead. Also, when using clone, it returns the instance, and doesn’t affect the original instance, so you should instead assign the clone to a variable.

So is there a solution to the problem?

Oh and uh Ik that part about the clone I did that because I don’t want it to return I just generally don’t want it there anymore yk?

When you clone an instance, it’s not affected.

And the solution is to move Jack2 to ReplicatedStorage

local player = game.Players.LocalPlayer

local KeyBoy = game.Workspace.Dresser2.Drawer.Key

local Jack = game.Workspace.Jack

local Jack2 = game.ReplicatedStorage.Jack2

local TriggerTheThing = Jack.ClickPart

TriggerTheThing.Touched:Connect(function(hit)

	if hit.Parent.Name == KeyBoy.Name then
		Jack:Destroy()

		local jack2Clone = Jack2:Clone()
		jack2Clone.Parent = game.Workspace;
	end
end)

Ah okay thank you so whenever I’m cloning I should always put it in replicated storage and not serverstorage? and Also when do I use serverstorage?

Use ReplicatedStorage for things you want LocalScripts to have access to.

And serverstorage for normal scripts to have access to?

Normal scripts also have access to ReplicatedStorage. I’d use ServerStorage for big things like maps; it’s better for performance.

Ah okay thank you! If I have an issue with the script I’ll make sure to let you know alright? But I appreciate the help!

1 Like

Whatever that’s inside ServerStorage will nevertheless replicate to the client and will not run, especially useful for module scripts. ServerScriptService is important for running normal server scripts.

Alright thank you for letting me know will try to not make the same mistake again just as how @ellienonekomimi told me as well

If the topic has been answered, please mark it as solved.

The client is not able to access places like serverstorqge, consider using replicatedstorage