My part clicker script isnt working

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)
1 Like

Try setting the position to the spawner.

robux.Position = script.Parent.Spawner.Positon
1 Like

As a tip, set the parent last after cloning something or inserting something via a script, it’s more efficient in terms of performance.

1 Like

I tried, dosen’t work (30 characters)

Ok, thank you for telling me
(30 chars)

1 Like

Need more context. Is ‘Spawner’ a part or a model?
If possible, please provide the output and a picture of the part and everything under it.

1 Like

Spawner is a Part Inside the “Tycoon” Model

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

Please try method #1 first

Ok thanks,I’ll try it out
(30 chars)

Both of them didn’t work, sadly enough

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.

As I get It, you want to the detector, open car popup GUI? or like that…

The output shows nothing,

I don’t understand what you’re trying to say

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

Oh. Try putting your tycoon in workspace.
Your script won’t run in a storage lel.

BTW, if that doesn’t work, refer to methods 1 and 2 again

I don’t think you understand what I’m trying to do, I want it so that when a Player clicks a Part, it spawns a Part named “Robux”

Ok I’ll try it
(30 chararacters)

Ah stop

Oh my god, words cannot explain how happy I am rn