Made a simple script, where you get an part from a warehouse/shop where it clones the part and puts it on your hand, but recently I've had an issue where the click detector function, to drop the item from the players hand, doesn't work when an item has been cloned.
After it has been cloned, the click detector function just doesn't work any longer. I've tried ways to combat the script just not working, by having it disabled until the part is actually out as it has worked in past similar projects, but this seems to be different.
Here is the clone script
itemlog= game.ReplicatedStorage.warehousestuff.itemswarehouse player = game.Players.LocalPlayer = script.Parent.Parent.Name script.Parent.MouseButton1Click:Connect(function() local item = script.Parent.Parent local clone = game.Lighting.stuff:FindFirstChild(name) local cloned = clone.drop:Clone() cloned.Parent = workspace.ItemHolderFolder:FindFirstChild(player.UserId) cloned.Weld.Part1 = player.Character.LeftHand cloned.Script.Disabled = false local Anim = player.Character.Humanoid:LoadAnimation(cloned.Script.Anim) Anim:Play() item:Destroy() end)
Here is the drop script:
weld = script.Parent.Weld item = game.Lighting.stuff.wood script.Parent.ClickDetector.MouseClick:connect(function(player) if script.Parent.name.Value == "N/A" then script.Parent.name.Value = player.Name Anim = player.Character.Humanoid:LoadAnimation(script.Anim) Anim:Play() weld.Part1 = player.Character.LeftHand drop = script.Parent drop.Parent = workspace.ItemHolderFolder:FindFirstChild(player.UserId) elseif script.Parent.name.Value == player.Name then script.Parent.name.Value = "N/A" Anim:Stop() weld.Part1 = nil drop.Parent = workspace end end)
I have a similar issue with my horse script, where you mount it by spawning it from a tool, where it teleport to the player and you have to click on it to mount the horse. Any help? :)
First of all, your :Clone()
script seems to be in a LocalScript. Indicating in line #3 on your first script or Clone script which isscript.Parent.MouseButton1Click:Connect(function()
(a TextButton Event). By means only
the player who clicked the gui in their client can only see the cloned object meaningfully only that player can see it and not the server itself. As for your second script, it wouldn't be possible for a ServerScript
to detect a ClickSetector
in a ClientSide so that will be my bet.
To fix this, you have to put your second script in the LocalScript
so that the script itself can see through your client and detect the ClickDetector
.