Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make an event script using function ?

Asked by 8 years ago

The script works fine, but when a player level is levels up like player is 24 and gets 25 it still keeps putting the gui up when it have to stop putting the gui up. How to fix it? I did put a green line text to everything.

Since the functions everything works better then my prevous onces. But now I only have that problem. I think i need a way to keep checking what level the player is.

game.Players.PlayerAdded:wait()

local player = game.Players.LocalPlayer
wait(2)
function bigger () --if bigger then 0
    player.leaderstats.Level.Value = player.leaderstats.Level.Value >= 0 
end
function smaller () -- if bigger then 25 it won't work for them
    player.leaderstats.Level.Value = player.leaderstats.Level.Value >= 25 
end

function level () -- function of level
    if bigger then -- if its bigger then 0 it wil get ready the gui
        local GuiEvent = script:findFirstChild("Easy"):Clone()
        GuiEvent.Parent = player.PlayerGui
    elseif smaller then -- if its bigger then 25 nothing hqs to happen
        print("level to high")
    end
end

while true do
    local Players = game:GetService("Players")
    Choos = math.random(1) 
    wait(15)
    if Choos == 1 then  -- event 1
        wait(2) 
        if level (smaller) then
            print("Moving to hard")
        elseif level (bigger) then
            print("Playing")
        end
        wait(21)
    end
end

Thanks

0
Your leaderboard is not working I mean the function bigger and smaller you always get the gui even if you delete line 6 and 9. minetrackmania 186 — 8y
0
How to fix this? wintershopSab 10 — 8y
0
I don't know, someone else must help you minetrackmania 186 — 8y
0
What do you -think- your script does? User#6546 35 — 8y
0
Look below I made a fix for you minetrackmania 186 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

Your problem was the functions were'nt working correct, So i made your bigger and smaller inside the event so it keeps checking, and I tested it out it works perfect but if you are going make like a really big event script you may need a way to make this part as an function

if player.leaderstats.Level.Value >= 24 then 
        print("IT WORKS")
    else
        if player.leaderstats.Level.Value <= 25 then
        local GuiEvent = script:findFirstChild("Easy"):Clone()
        GuiEvent.Parent = player.PlayerGui
        end
        end

If you find out how it only take you like 5 lines to create an event each time like example:

if Choos == 1 then -- Count this as 1
        wait(2) --Its up to you put a loading line
        game.ServerStorage:findFirstChild("YOUR MODEL NAME HERE"):clone().Parent = game.Workspace -- putting in workspace
        wait(500) -- time you want it in the game
        game.Workspace:FindFirstChild("SAME MODEL NAME HERE"):Destroy() -- destroying
        wait(5) -- Its up to you put a loading/removing line
    end

So 7 lines if you remove two waits you have like 5 but don't forgot to add the function!

Here is the script with the function in the event:

game.Players.PlayerAdded:wait()

local player = game.Players.LocalPlayer

while true do
    local Players = game:GetService("Players")
    Choos = math.random(1) 
    wait(15)
    ----------------------------------------------------------------------
    if Choos == 1 then
        wait(2) 
        if player.leaderstats.Level.Value >= 24 then 
        print("IT WORKS")
    else
        if player.leaderstats.Level.Value <= 25 then
        local GuiEvent = script:findFirstChild("Easy"):Clone()
        GuiEvent.Parent = player.PlayerGui
        end
        end
        wait(5)
    end
    ------------------------------------------------------------------
end

I hope this helped you out! Vote up if you thinks it helped u!

Ad
Log in to vote
0
Answered by
Hasburo 150
8 years ago
game.Players.PlayerAdded:wait()

local player = game.Players.LocalPlayer

function level () -- function of level
    if player.leaderstats.Level.Value = player.leaderstats.Level.Value >= 0  then
        local GuiEvent = script:findFirstChild("Easy"):Clone()
        GuiEvent.Parent = player.PlayerGui
    elseif player.leaderstats.Level.Value = player.leaderstats.Level.Value >= 25  then
    local Problem = player.PlayerGui:WaitForChild("Easy")
           Problem:Destroy()
        print("level to high")
    end
end

while true do
    local Players = game:GetService("Players")
    Choos = math.random(1) 
    wait(15)
    if Choos == 1 then  -- event 1
        wait(2) 
        if level (smaller) then
            print("Moving to hard")
        elseif level (bigger) then
            print("Playing")
        end
        wait(21)
    end
end

I didn't take a good shot at solving your problem, and for that I apologize. I'm running late for school. Good luck!

Answer this question