-
I need help to make a script that, when clicked from a player, clones a group, spawns it in the workspace, and works on client side only.
-
The script already works, but if i put it on a local script it doesn’t, i tried in many ways
-
I tried to put it inside a part, in the server script service and changing it up a bit.
This is my current script:
local players = game:GetService("Players")
local part = script.Parent
local renderableClone = nil
part.ClickDetector.MouseClick:Connect(function(player)
if (player.Character.Head.Position - part.Position).unit:Dot((part.CFrame.lookVector)) > 0 then
print("Script started")
if renderableClone then
print("Condition satisfied")
renderableClone:Destroy()
renderableClone = nil
else
print("Cloning renderable")
local renderable = ReplicatedStorage:WaitForChild("renderable")
renderableClone = renderable:Clone()
renderableClone.Parent = workspace
renderableClone.CFrame = part.CFrame
end
end
end)
So basically inside a part, i have 2 scripts, one that changes his property “can collide” on and off when clicked, and the other is the one i’ve written above.
When a player clicks the part, while standing in front of it, it makes the player able to pass trough it and spawns a group, but if you click it from the other side it doesn’t work, the other scripts continue to change the “can collide” on and off, so it’s like a working door, but the group only appears and disappears when you click the part from the front. So the player can’t see the group disappear and appear, optimizing the game.
Now my problem is, making this script client side only, where do i need to put my local script? Do i just need to copy this one and put it somewhere? I can’t find the solution, thanks.