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

Tools script works in other tools how do i fix?

Asked by 3 years ago
local Tool = script.Parent
local Debris = game:GetService("Debris")
local Event = Tool.Mouse
local cooldown = false
local cooldowntime = 10 -- cooldown time

Event.OnServerEvent:Connect(function(plr,mouse)
print(mouse) -- prints where u clicked in output
if Tool.Parent then -- checks if tool has a parent , aka the player. So this is good so it wont spawn if u die when clicking.
if cooldown == false then
cooldown = true
            local Model = game.ReplicatedStorage.Rocks:Clone() -- cloning model from serverstorage
            print "worked"
Model.Parent = workspace -- needs a parent of workspace so u can see it.
Model:GetPrimaryPartCFrame(Model:SetPrimaryPartCFrame(mouse)) -- setting the primarypart to mouse position
Debris:AddItem(Model,10)-- just removes the model after 10 seconds, you can delete this if you want.
wait(cooldowntime) -- adds a cooldown, if you dont want any cooldown just remove all cooldown lines and remove 1 end.
cooldown = false
end
end
end)

This is a spawner that spawns a model from replicated storage it works fine if i only have 1 tool but if i want another one this script works on that tool too how do i fix that

Answer this question