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

Code won't work for claming a land for a player to own and build on?

Asked by 7 years ago

I'm trying to have a claim area. Player steps on a brick then the plot I make will be theirs. But the script isn't working.

This is the code within the brick they step on to own the plot:

local ting = 0
owner = script.Parent.Parent.Parent.Owner

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)
        owner.Value = hit.Parent.Name
        if user.isOwner.Value == 0 then
        user.isOwner.Value = 1
        local message = Instance.new("Message")
        message.Text = "You now own this Building!"
        message.Parent = user
        script.Parent.Parent:remove()
        wait(3)
        message:remove()
        end
    end

    ting = 0
    end

end

script.Parent.Touched:connect(onTouched)

And this is the script within the plot to be claimed:

name = script.Parent
owner = name.Parent.Owner

while true do
if owner.Value ~= "" then
name.Name = owner.Value .. "s Building!"
else
name.Name = "Nobodys Building!"
end
wait(2)
end

0
So basically like in a tycoon? Meltdown81 309 — 7y

2 answers

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago
name = script.Parent
owner = name.Parent.Owner

while true do
    if owner.Value == "" then --Check if it is equal to nothing then it changes the owners value.
        name.Name = owner.Value .. "s Building!"
    else
        name.Name = "Nobodys Building!"
    end

    wait(2)
end
0
I got it to work. Thank you so much. MatthewLickster 15 — 7y
0
NP so much! FiredDusk 1466 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

isOwner isn't native to the player object. You'll have to add it in through a script. Put this script in ServerScriptService

game.Players.PlayerAdded:connect(function(player) local o = Instance.new("IntValue",player) o.Name = "isOwner" o.Value = 0 end)

Also add the message to user.PlayerGui otherwise they won't see it and instead of wasting a whole script on changing the name of the model just change it when the character touches it, but before the script deletes itself.

0
Please put the script in a codeblock Valatos 166 — 7y
0
Thanks. Kind of new here. Meltdown81 309 — 7y

Answer this question