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

My private GUI's give cash script is not working. What is the problem in my script?

I am making a GUI which is only visible to me. I can give cash to any player using that GUI. This may sound weird but I am doing it to test the new items I add. I want to add a function that if I say others then every one, except me, in the server's cash value will change to the given cash value. Here is the script. It is not working. It gives cash to others but it gives it to me too.

elseif name.Text == "others" or "Others" then
	local children = game.Players:GetPlayers()
	for i,v in pairs(children) do
		if v.Name ~= "StrategicPlayZ" then
			v.leaderstats.Cash.Value = v.leaderstats.Cash.Value + value
		end
	end
end

Please tell me what is the problem here and how do I fix it. Thanks!

And by the way the script does not shows any error in the output. It just gives cash to others but to also.

5 comments

0

Is this a LocalScript or a Script? Is your script erroring? name.Text == "others" or "Others" will not work as expected.

0

It is in a script. The script runs when a remote event is fired. And the script is not erroring.

0

ok, can you print v.Name?

0

I did print v.Name but it didn't print anything.

0

That's really weird

1 answer

✓ Accepted answer

Explanation

I'm not entirely what the issue is but I will try to help as much as possible.

The Solution

Before I start explaining I just want to note that having a Gui that can give players money is probably not the safest feature to have in your game. It could be exploited by people who can execute scripts in your game. For this, I recommend making a chat command that runs on the server (very crucial) that would change all of that and etc.

It might help to change the for loop a little bit for this case. It way or may not work. If it doesn't leave a comment on this answer of the error message and where it was.

This might fix your code:

elseif name.Text == "others" or "Others" then
	    local children = game.Players:GetPlayers()
	    for i = 1, #children do
		if children[i].Name ~= "StrategicPlayZ" then
			children[i].leaderstats.Cash.Value = children[i].leaderstats.Cash.Value + value
	        end
	end
end

If you have any other questions or comments, just reply to this answer! :)

-Crystal

1 comment

0

Ok I will test your code.

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