I am trying to make it so that when you click a Part with a ClickDetector, it creates another one where “Spawner” is located, basically like a Tycoon.
My Code dosen’t work, I have watched a lot of tutorials and devforum posts but I just can’t get it to work.
Please help me, here’s my code
local db = true
script.Parent.ClickForCash.ClickDetector.MouseClick:Connect(function()
if db == true then
db = false
local robux = game.ServerStorage.Robux:Clone()
robux.Parent = workspace
robux.CFrame = script.Parent.Spawner.CFrame + Vector3.new(0,0.1,0)
robux.FormFactor = "Custom"
game.Debris:AddItem(robux,60)
wait(0.05)
db = true
end
end)
Try changing ‘local robux = game.ServerStorage.Robux:Clone()’ to
local robux = game:GetService(“ServerStorage”).Robux:Clone()
Because idt you can access it without using GetService. Though if it doesn’t work, then try putting robux into workspace and cloning it from there like:
local robux = workspace.Robux:Clone() – YOU HAVE TO MOVE ROBUX TO WORKSPACE FIRST
Whats the error? And pic of the click detector part showing everything inside it.
There is nothing wrong with the code, so it must be a mistake on your part. We need more context.
Put givestats remote event, In Click Detector and then, try this script…
local remoteevent = script.Parent.Parent.givestats
game.Players.PlayerAdded:Connect(function(plr)
script.Parent.Parent.Parent.ClickDetector.MouseClick:Connect(function()
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 1
if not plr.leaderstats.Cash.Value + 1 then
remoteevent = script.Parent.Parent
remoteevent:FireServer()
end
end)
end)
-- I hope it helps