Advertisement
XxxLloyd061302xxX

Script for the "Head"

Jul 5th, 2018
7,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. local houseprice = 1000 -- The price of the house
  2.  
  3. script.Parent.Touched:connect(function(part)
  4.     if part.Parent:FindFirstChild("Humanoid") then
  5.         if game.Players:FindFirstChild(part.Parent.Name).leaderstats["Cash"].Value >= houseprice then-- Cash is my currency. Change it to your currency name.
  6.             if not game.Workspace:FindFirstChild(part.Parent.Name.."'s House") then -- Finds if the player has an existing house.
  7.                 if script.Parent.Parent.Parent.Owner.Value == "" then -- Make sure this house has no owner.
  8.                     game.Players:FindFirstChild(part.Parent.Name).leaderstats["Cash"].Value = game.Players:FindFirstChild(part.Parent.Name).leaderstats["Cash"].Value - houseprice -- Deducts the cost of the house to the player's cash
  9.                     script.Parent.Parent.Parent.Owner.Value = part.Parent.Name -- We change the "Owner" stringvalue to the name of the player who bought the house.
  10.                     script.Parent.Parent.Name = part.Parent.Name.."'s House" -- Change the "Buy this house!" to the name of the owner
  11.                     script.Parent.Parent.Parent.Name = part.Parent.Name.."'s House" -- Change the house name to the owner's name to make it easy to find when the player left
  12.                 end
  13.             end
  14.         end
  15.     end
  16. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement