Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Local script not working in published - cloning model to player's camera?

Asked by 7 years ago

I have a script that duplicates a model from ServerStorage and sends it to the player's camera. It works in studio, but not in published mode.

game.ReplicatedStorage.rings.rings1.OnServerEvent:Connect(function(plrWhoFiredEvent)
    game.ServerStorage.rings:Clone().Parent = workspace.Camera
    wait(210)
    workspace.Camera.rings:Remove()

end)

0
ServerStorage is for the server only not the client. Also local scripts do not run in the workspace. User#5423 17 — 7y
0
this local script is inside ServerScriptService, and I tried running it out of Lighting, it also doesn't work callmehbob 54 — 7y
0
(putting the model in lighting instead of serverstorage, i mean, not the local script - for testing purposes) callmehbob 54 — 7y

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

Problems

It seems that you have a networking issue. You setup an OnServerEvent event to clone the models into the clients Camera.

This is a problem because you can only access the camera on the client, and OnServerEvent events are for the server. You have a backwards setup you see?


Solution

What you can do is reverse your setup so that you have the server calling a FireClient function, and the client receiving it using the OnClientEvent event.

Your setup would look like this;

Workspace

Script --> 'FireClient' on RemoteEvent.

ReplicatedStorage

RemoteEvent

StarterPack

LocalScript --> 'OnClientEvent' on RemoteEvent.


Note: Remove is deprecated! Use Destroy!

If you have any further questions feel free to ask.

Happy developing!

Ad

Answer this question