#why is my script not responding
1 messages · Page 1 of 1 (latest)
hints are deprectaed and you probably shouldnt use them, and also you disable the script whenever anyone joins the game is that what you are trying to do?
hints arent deprecated
bruh
roblox sucks
plus im trying to make an loop
without while true do
@warped wraith also ignore the script.enable = false
i didnt mean it to put there
** You are now Level 1! **
and you might want to change the text from "The game must need more than 4 players to start" to "The game needs more than 4 players to start"
- When you get back, let me know what the goal of the script is. I think I can help you out.
local datatext = Instance.new("Hint",workspace)
datatext.Text = "There must be more than 4 players for the game to start."
repeat task.wait()
until #game.Players:GetChildren() ~= 0
local playersR = game.Players:GetChildren()[math.random(1, #game.Players:GetChildren())] -- gets a random player
local StartTime = 10 :: number
task.delay(StartTime, function()
datatext.Text = "Begin."
end)
Here's my take on what I believe you were trying to do?
This script creates a hint at the top, gets a random player from the player list (which will only be one player but thats up to you) and then waits a select amount of time before saying begin in the hint
basically, the goal of the script is, first it detects if there is more than 0 players.
Then, it kills a random player then sets it on a team called "Aliens".
now it gives everyone from a team called "Marines", pistol, they give the Marines pistols. (Pistols are from Lighting).
and yeah
Yeah, the script i sent waits for there to detect more than 0 players then runs the rest of the logic you had written. From there, you can kill playersR and add further logic to complete your goal
what you already had should be working if you follow my model
❤️
Your problem was the script was running before the player loaded in
so it was grabbing a random number from 1-0
which math.random cant do
and it ended up just breaking your code
also, a question.
how do i make all players from the marine team get the pistol item?
it seems i put the for i,v then ipairs(idk) and that thing
but it just doesnt work...
can you send that script too? preferably using ``lua to send a code block through discord
but yeah you want to sort through the team's players using for loops
``local GetPlayers = game.Teams.Marines:GetPlayers()
--> Assigning it as a local variable is faster.
for _, Target in ipairs(GetPlayers) do
pistol.Parent = Target.Backpack
print(Target.Name)
end
oops
when the script runs, what does it print as Target.Name
what.? 😭
all g
does your script wait to make sure there are people on the Marine team before iterating throught the players
no
If you add a check it would prob work
same thing I added in your first script
just wait untill someone joins the team to run the iteration
ok
(sorry for pinging)
but why this script just loops the noise?
the "noise" is defeat.
the looped noise is 'Laugh'?
you have it in a while loop so it is checking constantly and playing it constantly
every tick it checks to see if there are more than 0 players and if not plays the noise
but you don't prevent it from playing more than once so once there are no players left alive, it just keeps playing it over and over
yeah
wait hold on
again
im delusional...
that was other script
oopsies
** You are now Level 3! **
the way your code block is structured makes the noise play over and over again
ohh
you can connect the function of lua if players < 0 then to the number of players on a team changing to avoid having to run it over and over again
I haven't really used Roblox's team feature but I'm sure theres a signal for when a player is added or removed from a team
Oh yeah its Team.PlayerRemoved
no problem 👍
most people avoid while loops for general purpose because they are expensive and normally don't suit functions the best
Usually there are other events that can be connected to your function to make it more efficient or you can use RunService's Heartbeat or RenderStepped to get constant checks
I reccommend checking those out if you haven't before
actually nevermind
im back bt
@warped wraith what i wanted to say is
that the script isnt transfering players to an team + kill all of them.
btw
the looped "wait()"s are to make the player fully from the team
** You are now Level 8! **
(when you die you become an ghost, if not killed by an alien)
if you get killed by an alien
you become an alien
Yeah you probably want to rewrite that
there's 100 different ways to make that better
when the player dies, check if the person who killed them was an alien and if so, change their team... once
if not, make them a ghost
no no
when YOU die.
you become an ghost
but if you get killed by an alien
you become an alien
get what i mean?
im just saying the spammed wait()s are so you cannot be an ghost while dying.
and it ignores the ghost team
then turns it into marine
gdt what i meangt?
Yes, but there are better ways to do that than using wait()
you should handle the team changing when you die instead to determine if they should be a ghost or an alien
i could not do that
its part of the game's lore.
when you die by yourself you become an ghost
Could you not add a check into the Humanoid.Died to see how they died
and then handle it accordingly from there?
???
oh right
uhm
okay so, when you die alone you become a ghost, when you die by and alien you become an alien
right?
aliens have an script that attacks marines
yes
but
im trying to fix another script.
this one
im just explaining the spammed wait()s
alr... whats the problem with that one other than the looping sound
a memory crossed by
ignore that
it was another problem
this part
is not working
im trying to make all the players die
then change team spammed by wait()s together
btw i talking about the loop sound
that was another problem + i was delusional.
nvm i found it out
i actually fixed it all
yay
Good 😊
also
i think its kinda enough since
like yesterday.
just one last script fixing pls
oh
like
you know you helped me right?
the main script, which you helped on me too, i edited it.
i edited some part but
for some reason it continues after being enabled again.
** You are now Level 9! **
so if you make the math
5+5+5+5+5+5 would be 30.
so when it reaches 30 seconds
the script somehow puts the victory message
making the game glitched
even worse it has the msg and hint
it looks weird
but im gonna show an video of that
Alr
please wait.
the video is being converted
please scroll at the end
not too far
or maybe watch the whole thing
no
what
what alien thing
ohh you mean the uh
team when death?
its supposed to be there
a random player gets choosen then dies
and becomes Alien
But the “aliens wiped out the planet” message
because there is no players in the marines team
Okay wait so explain what you are trying to fix one more time
** You are now Level 4! **
did you see the full video
at the end
you see the messages are together...
and it isnt supposed to be like that
since i made an 30 second wait
to make the victory thing happen
if marines survive long enough.
wait(30)
local msg = Instance.new("Message", workspace)
msg.Text = "Humans Won."
workspace.ambiencecontroller.Enabled = false
for i, v in pairs(game.Players:GetChildren()) do
local char = v.Character
char:WaitForChild("Humanoid").Health = 0
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
end
game.StarterGui.Victory:Play()
wait(3)
msg:Remove()
workspace.Gothic:Play()
workspace.Close.CanCollide = true
workspace.Close.Transparency = 0
script.Enabled = true
``lua wait(30)
local msg = Instance.new("Message", workspace)
msg.Text = "Humans Won."
workspace.ambiencecontroller.Enabled = false
for i, v in pairs(game.Players:GetChildren()) do
local char = v.Character
char:WaitForChild("Humanoid").Health = 0
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
v.Team = game.Teams.Marines
v.leaderstats.Status.Value = "Alive"
wait()
end
game.StarterGui.Victory:Play()
wait(3)
msg:Remove()
workspace.Gothic:Play()
workspace.Close.CanCollide = true
workspace.Close.Transparency = 0
script.Enabled = true``
Ill Wait.....
done?
WHAT
I FIXED IT
NVM NVM
sorry im at work rn so it takes a minute
its ok.
also im kinda sorry wasting your time since i already fixed it all completly
@warped wraith Hello.
today i wanna ask one question.
Why is my script only giving one player gun instead of all the team?
clone the pistol for each player
ok
also, why is this script not working?
im trying to make it so when you click it
it first detects if you have an gamepass.
then it gives you the item.
is it a local script
put a print inside the buy() function to make sure it runs when the button is clicked
ok
wait
it isnt working because i didnt enable that api thing?
you should prob allow API access
idk how it works with MPS though
check your console
should i put the print like
first line in the function, just to see if it even runs
:Connect(buy, print("Buy"))
👍
always check console first
you can enable it in studio by using the 'output' toggle
oh ok
sorry for pinging too early but.
i noticed that my script detects if an value is true
along with an wait(480) in the top.
so i assume that
when the wait completes
it detects if the value is true
and makes an event happen.
it can happen any time when a round starts
or ends