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

How to make an event script?

Hello, How to make an event script that lets play only the players that have an level between 0 and 25 or if they have points between 0 and 200

Players higher I will make a second event script (just saying)

Their are no errors but the problem is the gui comes at the screen even if the value is higher then 25.

script in workspace

game.Players.PlayerAdded:wait()

while true do
	local Players = game:GetService("Players")
	function onPlayerAdded(player)
    print(player.Name .. " is waiting")
	end -- getting players
	Choos = math.random(1) --Will be added soon more 
	wait(15)
	if Choos == 1 then -- Event 1
		wait(2) --loading
		for _,player in pairs(Players:GetPlayers()) do 
     	onPlayerAdded(player) -- getting player
		local unlock = player.leaderstats.Level.Value -- value of player
		local unlockPo = player.leaderstats.PointsNL.Value -- value of player
		if unlock >= 0 then -- if player has bigger then level 0
			b = script:findFirstChild("Easy"):Clone() -- copying to player gui
			b.Parent = player.PlayerGui
		elseif unlock >= 25 then -- if player has bigger then 25 nothing have to happen to that player
			print("Going to hardmode")
		end
		end
		wait(21) --when round is over
	end
end

thanks :3

2 comments

0

what's the error?

0

Their are no errors but the problem is the gui comes at the screen even if the value is higher then 25.

1 answer

The problem is with your condition in your if statement on line 16.

Your first condition is unlock >= 0 and then you second is unlock >= 25. So lets say that the variable unlock is equal to 30. It will start with the first condition, 30 >= 0, but that returns true! It will do everything in that block and won't even check your second condition!

To fix this you can simply change the order of each condition:

if unlock >= 25 then
	-- Do stuff for unlock >= 25
elseif unlock >= 0 then
	-- Do stuff for 0 <= unlock < 25
end

1 comment

0

It is an good answer but i cant put under 25 a code because of an because I work with two scripts one for hard and one for easy

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