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
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
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.