Welcome to the Forums!
Join thousands of other Roblox members with a free account.
Create Forum Account

Sell Area LocalScript Problem.

  • This website was created by Roblox members to replace the official forums (because Roblox shut them down) Join us if you like Roblox!

Projosh00

New Member
Reputation: 0 / 0 / 0
Feb 20, 2021
3
0
1
Roblox
donotgivemepets77
Hello, My name is donotgivemepets77.
I have been working on a simulator game lately and my script isn't working.

I would really much appreciate your help.
Here is the script.
1620069187206.png

If you need to test it out, here is the script in text.

========== Script ==========

-- Variables
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local Clicks = leaderstats:WaitForChild("Clicks")
local Money = leaderstats:WaitForChild("Money")
local debounce = false

-- Functions
script.Parent.Touched:Connect(function(HIT)
local H = HIT.Parent:FindFirstChild("Humanoid")
if H then
if not debounce then
local CheckIfClicks = Clicks.Value>= 0
if CheckIfClicks then
Money.Value = Money.Value + Clicks.Value*1
debounce = true
wait(1)
debounce = false
end
end
end
end)
 
Solution
In workspace, you can only use regular scripts. A local script won't work.

To get the player to add money to, you can do:
Lua:
local player = game.Players:GetPlayerFromCharacter(HIT.Parent)
Move all your variables inside the function.