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

Error shows up when I try to check player's name. click detector?

Asked by
RootEntry 111
5 years ago

I am trying to make a house owning script. But a error shows up when I try.

Error: "18:01:35.064 - Workspace.House1.Door.Script:20: attempt to index field 'Value' (a nil value)"

Script:

local occupied = false
local price = 500000

script.Parent.ClickDetector.MouseClick:connect(function(player)
    repeat
        wait()
    until player.Character
    if player:WaitForChild("HouseObject").Value == nil then
        if occupied == false then
            if game:GetService("ServerStorage"):WaitForChild("Data"):WaitForChild(player.Name.."Cash").Value >= price then
                script.Parent.PlayerObject.Value = player
                player:WaitForChild("HouseObject").Value = script.Parent.Parent
                occupied = true
                game:GetService("ServerStorage"):WaitForChild("Cash").Value = game:GetService("ServerStorage"):WaitForChild("Cash").Value -price
                print(player.Name.." bought a house.")
            end
        end
    end
    wait(.1)
    if player.Name == script.Parent.PlayerObject.Value.Name then
        script.Parent.CanCollide = false
        wait(3)
        script.Parent.CanCollide = true
    else
        script.Parent.CanCollide = true
    end
end)

game.Players.PlayerRemoving:connect(function(player)
    script.Parent.PlayerObject.Value = nil
    player:WaitForChild("HouseObject").Value = nil
    occupied = false
end)
0
What exactly is PlayerObject? If it is a Value, which type of value is it? Otherwise, what object is it? lunatic5 409 — 5y
0
Ty for ryping my question out, lunatica. marketmanager1 52 — 5y
0
It i's a objectvalue RootEntry 111 — 5y

Answer this question