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

When I add = into a script, it works, if its + then it doesn't work, why?

Ok, please help; heres the script:

local people = player.opeople.oPeopleOnBoard.Value
	local cash = player.leaderstats.Cash.Value
	
	print(player.opeople.oPeopleOnBoard.Value)
	-- for the thing make money first, so:
	-- player.leaderstats.Cash.Value = player.opeople.oPeopleOnBoard.Value
	 player.leaderstats.Cash.Value = player.opeople.oPeopleOnBoard.Value


	player.opeople.oPeopleOnBoard.Value = script.Parent.Parent.One.Value
	player.tpeople.tPeopleOnBoard.Value = script.Parent.Parent.Two.Value
	player.rpeople.rPeopleOnBoard.Value = script.Parent.Parent.Three.Value
	
	player.PlayerGui.GUI.Main.One_Value.Text = script.Parent.Parent.One.Value
	player.PlayerGui.GUI.Main.Two_Value.Text = script.Parent.Parent.Two.Value
	player.PlayerGui.GUI.Main.Three_Value.Text = script.Parent.Parent.Three.Value
	
	
	local name = script.Parent.Parent.Name

on line

 player.leaderstats.Cash.Value = player.opeople.oPeopleOnBoard.Value

if I change the "=" to a "+" the whole scripts disables. First off, what i'm trying to do is when the player does something, I want the people on board of that vehicle to disembark and pay the driver, thus giving the driver (player) more money when the passengers (npcs) get off, if you don't get that, add the people on board to the money of the player. Help!

1 answer

✓ Accepted answer

player.leaderstats.Cash.Value + player.opeople.oPeopleOnBoard.Value

This errors because this is not actually setting a value. Instead getting what Cash + PeopleOnBoard. To set the value do:

player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + player.opeople.oPeopleOnBoard.Value

Then you'll see it is actually setting a value.

1 comment

0

thank you sooo much!

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