Local Script Troubles

I made the Simplest of scripts and it doesn’t work. Your supposed to click on the Model’s hitbox, then I use Destroy() to make my model Get deleted from the client. It’s also supposed to play a sound once it gets removed (Turned on in the Properties)
Here’s the Script:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	game.Workspace.ExampleModel:Destroy()
end)

Literally all it does is Destroy the model. That’s all I want it to do. Any Fixes?

Is there anything more? It seems incomplete to me

1 Like

You can just have the MouseClick event in a server script and then have a remote event fire to the client…

That’s All of the script. It’s that short line of code, and it doesn’t work :expressionless:

Maybe it’s because you are not defining the localPlayer

You are using a part in the workspace so you need to use a Server Script.

Use a GUI if you want it to be for the Client only.

How to Do that? I don’t really use RemoteEvents.

script.Parent.ClickDetector.MouseClick:Connect(function(player)
script.Parent:Destroy() -- depends if the script's parent is the model you want to destroy
-- for the sound now
local soundname = game.SoundService.soundname
soundname:play()


(by the way can we get more informations on what script you used, picture of the workspace, and properties pictures please.)

  1. local script or script
  2. did you try with remotevents ?
  3. have you looked on the forum for similar problems before posting ?

Basically, you create a remote event in ReplicatedStorage
just follow this script:

local cd = script.Parent.ClickDetector
local event = game.ReplicatedStorage.RemoteEvent
cd.MouseClick:Connect(function(plr)
   event:FireClient(plr)
end)

now on the client

local event = game.ReplicatedStorage.RemoteEvent
event.OnClientEvent:Connect(function(plrSentBy)
    workspace.Model:Destroy() -- put ur model path here
end)

Thanks Everyone for the help. I found out what the problem was. I just had to put the script in StarterPlayer → StarterPlayerScripts :laughing:
Thanks, And sorry for the trouble

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.