Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

currency . Value - amount?

Asked by 6 years ago

I made a script that when a player touches the door, the house becomes theirs and lets say 75 dollars is deducted from the players money. I suck at scripting, and this doesnt work i need help....

things to know -- the leaderstats script is located in workspace

local debounce = false
local player =  game.Players.LocalPlayer
local money = game.Workspace.Leaderstats('Money')
local amount = script.Parent.Parent.Price
function onTouch(hit)
if hit == nil then return end
if hit.Parent == nil then return end
if not game.Workspace:FindFirstChild("Home"..hit.Parent.Name) then
if game.Players:findFirstChild(hit.Parent.Name) ~= nil and debounce == false then
debounce = true
local b = script.Parent.Parent:Clone()
b.Parent = game.Lighting
b.Name = "Home"..hit.Parent.Name
wait(.4)
script.Parent.Parent.Ay.Value = hit.Parent.Name
if money >= amount then
    money.Value = money.Value - amount
end
script.Parent.Head:Remove()
script.Parent.Parent["Home: Nobody"].Name = "Home: "..hit.Parent.Name
script.Parent.Parent.Parent.Name = "Home"..hit.Parent.Name
end
else
end
wait(3)
debounce = false
end

script.Parent.Head.Touched:connect(onTouch)

1
have you heard of the tab key hiimgoodpack 2009 — 6y
1
What are the errors in the output Viking359 161 — 6y
0
@hiimgoodpack, not really, sounds like something new... greatneil80 2647 — 6y
0
Can I see your leaderstats script? awfulszn 394 — 6y
0
If this is a LocalScript, it is not supposed to be in Workspace. If it is a ServerScript then, you can't use game.Players.LocalPlayer. You should put your ServerScripts in ServerScriptService. Plus, remove is deprecated and use Destroy. However, if you want to make the parent nil, then just do [objectName].Parent = nil; connect is also deprecated so use Connect. Finally, Lighting is not a place fo saSlol2436 716 — 6y

Answer this question