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.
ServerStorage can't be used within Local Scripts, try changing the location of the items from ServerStorage to ReplicatedStorage.
http://wiki.roblox.com/index.php?title=API:Class/ServerStorage
Localplayer can't also be used in Server Scripts, you can easily get the player using the ClickDetector's function.
http://wiki.roblox.com/index.php?title=API:Class/ClickDetector
script.Parent.ClickDetector.MouseClick:connect(function(Player) local cash = Player:FindFirstChild('leaderstats').Cash local selectedPart = Player:FindFirstChild('leaderstats').SelectedPart if (selectedPart.Value == 'Bad Conveyor') then cash.Value = cash.Value - 450 local clone = game.ReplicatedStorage.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.ReplicatedStorage.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.ReplicatedStorage.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.ReplicatedStorage.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.ReplicatedStorage.SuperFastConveyor:Clone() clone4.Parent = game.Workspace clone4.Position = script.Parent.Position else print("ERROR") end end)