Script no longer want work after got cloned with a LocalScript

Hey,
I am creating a shop and in this shop, players can see the weapons model and I clone the models with a LocalScript and not with a Script so that the players don’t see the model of others in the same place.
The problem is that each model got a Script and when the model is cloned the Script into the model doesn’t want to work anymore.

I tried to disabled the Script that it into the model and when it gets cloned I enabled it, but it doesn’t work.

Can someone help me? :thinking:

– This is how the models are cloned and the place of the Script which no longer wants to work after being cloned.
https://streamable.com/jupoxg

3 Likes

You can’t execute server code if the server script only exists on the client.

1 Like

the models are cloned from ReplicatedStorage

and the script is just a Click script

script.Parent.ClickDetector.MouseClick:Connect(function()
	print("Clicked...")
end)

the problem is when I click the model its dont want print (Clicked…)

Oh, sorry! I misunderstood what you meant before. Read what @Tom_atoes said and try fixing your issue from there, if you need any help - reply to this post.

1 Like

sorry but can you explain more about what you just said here I didn’t understand

Server scripts (“normal” scripts) can only run on the server. When you clone the model with a local script (on the client) the server cannot run that script as it doesn’t exist on the server.

1 Like

ok now I understand thanks
but what I must do? to make it work :thinking:
edit: how I can make that the models detect the click of the player

Run your code in a local script.

I tried this one too but it doesn’t work
edit: you mean I put the Click script into a LocalScript? yes I already did that, still not working

I don’t believe local scripts run in the workspace, you will need to run this code from PlayerScripts. I’d recommend using CollectionService to tag the currently active model so you can access it easily.

1 Like