I'm making a house purchase brick so when you touch it, it'll remove the stats/money and make you owner of the house.
But it says on line 25 "attempt to compare userdata with number" and I do not understand what it means, Could someone help?
Here's the script:
local ting = 0
owner = script.Parent.Parent.Parent.OwnerName
function onTouched(hit)
if ting == 0 then
ting = 1
check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
if (user:FindFirstChild("rig") ~= nil) then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local message = Instance.new("Message")
message.Text = "You already own a house"
message.Parent = user
wait(3)
message:remove()
else
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr.leaderstats.Money <= 1500 then
local money = game.Players:GetPlayerFromCharacter(hit.Parent).leaderstats.Money
money.Value = money.Value -1500
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
owner.Value = hit.Parent.Name
local own = Instance.new("IntValue")
own.Name = "rig"
own.Parent = user
local message = Instance.new("Message")
message.Text = "House Purchased"
message.Parent = user
wait(3)
message:remove()
script.Parent.Parent:remove()
end
end
end
end
ting = 0
end
script.Parent.Touched:connect(onTouched)

2 comments
i like how 3 answers came up within 1 minute of each other
yes but mine is the best