Ok, so here's the code:
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character
local player1 = game.Players.LocalPlayer
wait(2)
local cash = player1:FindFirstChild('leaderstats').Cash
local selectedPart = player1:FindFirstChild('leaderstats').SelectedPart
function onClicked(playerWhoClicked)
if (selectedPart.Value == 'Bad Conveyor') then
cash.Value = cash.Value - 450
local clone = game.ServerStorage.BadConveyor:Clone()
clone.Parent = game.Workspace
clone.Position = script.Parent.Position
elseif (selectedPart.Value == 'Slow Conveyor') then
cash.Value = cash.Value - 750
local clone1 = game.ServerStorage.SlowConveyor:Clone()
clone1.Parent = game.Workspace
clone1.Position = script.Parent.Position
elseif (selectedPart.Value == 'Normal Conveyor') then
cash.Value = cash.Value - 1250
local clone2 = game.ServerStorage.NormalConveyor:Clone()
clone2.Parent = game.Workspace
clone2.Position = script.Parent.Position
elseif (selectedPart.Value == 'Fast Conveyor') then
cash.Value = cash.Value - 1750
local clone3 = game.ServerStorage.FastConveyor:Clone()
clone3.Parent = game.Workspace
clone3.Position = script.Parent.Position
elseif (selectedPart.Value == 'Super Fast Conveyor') then
cash.Value = cash.Value - 2100
local clone4 = game.ServerStorage.SuperFastConveyor:Clone()
clone4.Parent = game.Workspace
clone4.Position = script.Parent.Position
else
print("ERROR")
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
I have a code that sets SelectedPart to 'Bad Conveyor', 'Slow Conveyor', 'Normal Conveyor', 'Fast Conveyor' or 'Super Fast Conveyor' so that isn't the problem.
It doesn't say any errors. It just won't work. Pls help. I'm a newbie to roblox lua.

7 comments
It is not a local script and there not just thye cloning that doesn't work. It's everything. But I can try it anyways.
TestingDisn't work. Tnx anywaysYou have "local player1 = game.Players.LocalPlayer" at the top of your script, you can only use that in a local script.
But if I put the code in a local script i don't work even in solo mode
The thing is that it work perfectly well in solo mode but not at all when the game is published
The thing is, you can't access LocalPlayers in server scripts. You made one of the most common mistakes. https://scriptinghelpers.org/blog/common-mistakes
Ok, sorry, but how do I fix it?
Try that.