I tried to add a "rig" value to a player when they purchase a house but it didn't seem to work I thought maybe the debounce was the problem but I changed it and nothing. Thank you for any help!!
``local ting = 0 --debouncer owner = script.Parent.Parent.Parent.OwnerName --This is the thing that holds the owners name
function OnPrompt(Player) if ting == 0 then --debounce check ting = 1 --activate debounce local check = Player.Character:FindFirstChild("Humanoid") --Find the human that touched the button
if check ~= nil then --If a human is found, then
local user = game.Players:GetPlayerFromCharacter(Player) --Find human among the players
local Data = game.ReplicatedStorage.Data:FindFirstChild(Player.Name)
if Player:FindFirstChild("rig") then
script.Parent.ProximityPrompt.ActionText.Text = "You already own a house" --Put text into the message
wait(3) --Wait to let the message display for a while
script.Parent.ProximityPrompt.ActionText.Text = "Claim House"
ting = 0 --remove debounce
return --exit the function
else
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataFolder = ReplicatedStorage:WaitForChild("Data")
local userObject = DataFolder:FindFirstChild(Player.Name)
if userObject then
local walletValue = userObject.Wallet.Value
if walletValue >= 5000 then
walletValue = walletValue - 5000
DataFolder:FindFirstChild(Player.Name).Wallet.Value = walletValue
owner.Value = Player.Name --save new owners name for later.
local own = Instance.new("IntValue")
own.Name = "rig"
own.Parent = user
script.Parent.ProximityPrompt.ActionText = "You now own this house!" --Put text into the message
script.Parent.Purchased:Play()
wait(1)
script.Parent.ProximityPrompt.Enabled =
false
else
script.Parent.ProximityPrompt.ActionText = "You don't have enough money to buy this house!"
wait(3)
script.Parent.ProximityPrompt.ActionText = "Claim House"
end
end
end
end
ting = 0 --remove debounce
end
end
script.Parent.ProximityPrompt.Triggered:connect(OnPrompt) --Start listening for button-touchers.``
