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

Completely stuck with tycoon points addition? Variables.

So, this is my code thus far. It errors on line 14, due to my variable of owner


script.Parent.Touched:connect(function(z)
	if script.Parent.Parent.Name == "UnOwnedTycoon" then
		script.Parent.Parent.Name = z.Parent.Name .. "'s tycoon"
		print(z)
		print(z.Parent)
		
	end
	owner = z.Parent.Name
end)

workspace.Reciever.Touched:connect(function(x)
	if x.Name == "FlyingMoney" then
		game.Players(owner)leaderstats.Points.Value = game.Players(owner)leaderstats.Points.Value + 1
	end
end)


1 answer

When trying to do that instead of FindFirstChild, you use brackets. Also you need a dot after the brackets (Make sure that "owner" is a string).

script.Parent.Touched:connect(function(z)
    if script.Parent.Parent.Name == "UnOwnedTycoon" then
        script.Parent.Parent.Name = z.Parent.Name .. "'s tycoon"
        print(z)
        print(z.Parent)
    end
    owner = z.Parent.Name
end)

workspace.Reciever.Touched:connect(function(x)
    if x.Name == "FlyingMoney" then
        game.Players[owner].leaderstats.Points.Value = game.Players[owner].leaderstats.Points.Value + 1 --Brackets and a dot, like that.
    end
end)

Otherwise the script works and is efficient enough.

2 comments

0

Thanks!

0

If he did a good job with his answer, accept it, and give him an upvote :P Upvoted

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