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

Problem with ClickDetector and Clone() ?

Asked by 4 years ago

OK. I've got a part of this game where the players need to go and collect ten of this particular part. The model is called IODOLLARS, not 10DOLLARS, and inside the model and then inside the ClickDetector is a script which looks like this:

local clickDetector = script.Parent

function onMouseClick()
    game.Workspace.VAR.moncol.Value=game.Workspace.VAR.moncol.Value+10
    if game.Workspace.VAR.moncol.Value==100 then
        game.Workspace.VAR.col.Value=true
    elseif game.Workspace.VAR.moncol.Value~=100 then
        print("more to go")
    script.Parent.Parent:Destroy()  

end
end
clickDetector.MouseClick:connect(onMouseClick)

The script works. No errors, or notes in the output. The variable 'moncol' is an IntValue which is stored within a folder called 'VAR' in the Workspace. 'moncol' is set to 0. Below is the script used to :Clone() the model after an event happens. The event is just a wait(3).

local original = workspace.IODOLLARS
    -- Create the model copy
local copy = original:Clone()
    -- Parent the copy to the same parent as the original
copy.Parent = original.Parent
    -- Move the copy so it's not overlapping the original
copy:SetPrimaryPartCFrame(CFrame.new(76.85, 3.05, 220.35))

There's several different points at which I've put each part. The problem is, the player can click on the part the same amount of times as the amount of players in the server. I think there might be an error with the :Clone() script, as in maybe it's like some kind of local clone? I don't know. Advice, scripting or explanation as to what is going on would be much appreciated. Thank you!

0
Is there a part too? Lava_Scripter 109 — 4y
0
Lava_Scripter there's just a part with a clickdetector, a script and a surfacegui with a textlabel inside with the text '$10'. Primrose_Studio 53 — 4y

Answer this question