Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

So basically like in a tycoon?

2 answers

✓ Accepted answer
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

2 comments

0

I got it to work. Thank you so much.

0

NP so much!

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.

2 comments

0

Please put the script in a codeblock

0

Thanks. Kind of new here.

This discussion is preserved as it was. New answers, comments, and votes are closed.