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

How do I make a buy house function?

Asked by 7 years ago
Edited by OldPalHappy 7 years ago

I would like to know how you make a house function where you click a button you own the house but the others can't access it. I tried to give a gui but that didn't work in online mode:

local player = game.Players.LocalPlayer
local door = script.Parent.Parent.Door

script.Parent.Touched:connect(function()
    workspace:WaitForChild("House").GUI:Clone().Parent = player:WaitForChild("PlayerGui")
    workspace:WaitForChild("House").Part.Script:Destroy()

    local owner = Instance.new("StringValue", workspace)
    owner.Name = "owner"
    owner.Value = player.Name
    wait(0.1)
    if script.Parent.Touched:connect(function()
        if not workspace:WaitForChild("owner").Value == player.Name then
            workspace[player.Name].Head:Destroy()
        else
            door.CanCollide = false
            wait(3)
            door.CanCollide = true
    end
end)

But it didn't want to work.

Answer this question