#why is my script not responding

1 messages · Page 1 of 1 (latest)

cyan patio
#

pls help

#

script:

warped wraith
#

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?

warped wraith
cyan patio
#

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

warped wraith
#

so is the problem that the hint doesnt pop up?

#

or what's the exact issue

carmine ospreyBOT
#

studio** You are now Level 1! **studio

warped wraith
#

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

cyan patio
warped wraith
#

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

cyan patio
#

Okay.

#

omg it works!

#

thank you so much man

warped wraith
#

❤️

#

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

cyan patio
#

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...

warped wraith
#

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

cyan patio
#

oops

warped wraith
warped wraith
#

what.? 😭

cyan patio
#

oh wait

#

nvm

#

i was delusional

warped wraith
#

all g

#

does your script wait to make sure there are people on the Marine team before iterating throught the players

warped wraith
#

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

cyan patio
#

ok

cyan patio
#

but why this script just loops the noise?

#

the "noise" is defeat.

warped wraith
#

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

cyan patio
#

wait hold on

#

again

#

im delusional...

#

that was other script

#

oopsies

warped wraith
carmine ospreyBOT
#

studio** You are now Level 3! **studio

warped wraith
#

the way your code block is structured makes the noise play over and over again

warped wraith
#

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

cyan patio
#

it worked

#

thanks

#

i should start learning way more variations

warped wraith
#

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

cyan patio
#

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

carmine ospreyBOT
#

studio** You are now Level 8! **studio

cyan patio
#

(when you die you become an ghost, if not killed by an alien)

#

if you get killed by an alien

#

you become an alien

warped wraith
#

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

cyan patio
#

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?

warped wraith
#

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

cyan patio
#

its part of the game's lore.

#

when you die by yourself you become an ghost

warped wraith
#

Could you not add a check into the Humanoid.Died to see how they died

#

and then handle it accordingly from there?

warped wraith
#

okay so, when you die alone you become a ghost, when you die by and alien you become an alien

#

right?

cyan patio
#

aliens have an script that attacks marines

cyan patio
#

but

#

im trying to fix another script.

#

im just explaining the spammed wait()s

warped wraith
#

alr... whats the problem with that one other than the looping sound

cyan patio
#

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

cyan patio
#

that was another problem + i was delusional.

#

nvm i found it out

cyan patio
#

yay

warped wraith
#

Good 😊

cyan patio
#

i think its kinda enough since

#

like yesterday.

#

just one last script fixing pls

warped wraith
#

Yeah I’m always here to help

#

Lmk if something else comes up

cyan patio
#

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.

carmine ospreyBOT
#

studio** You are now Level 9! **studio

cyan patio
#

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

warped wraith
#

Alr

cyan patio
#

please wait.

#

the video is being converted

#

please scroll at the end

#

not too far

#

or maybe watch the whole thing

warped wraith
#

So the problem is it keeps starting?

#

Or

cyan patio
warped wraith
#

Oh wait

#

The alien thing isn’t supposed to be there right

#

?

cyan patio
#

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

warped wraith
#

But the “aliens wiped out the planet” message

cyan patio
#

because there is no players in the marines team

warped wraith
#

Okay wait so explain what you are trying to fix one more time

carmine ospreyBOT
#

studio** You are now Level 4! **studio

cyan patio
warped wraith
#

Yes

#

The xenomorph screen?

cyan patio
#

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

warped wraith
#

sorry im at work rn so it takes a minute

cyan patio
#

also im kinda sorry wasting your time since i already fixed it all completly

cyan patio
#

@warped wraith Hello.

#

today i wanna ask one question.

#

Why is my script only giving one player gun instead of all the team?

warped wraith
#

clone the pistol for each player

warped wraith
#

each player

#

make the clone inside the for loop

cyan patio
#

ok

cyan patio
#

im trying to make it so when you click it

#

it first detects if you have an gamepass.

#

then it gives you the item.

warped wraith
#

is it a local script

cyan patio
#

no

warped wraith
#

put a print inside the buy() function to make sure it runs when the button is clicked

cyan patio
#

wait

#

it isnt working because i didnt enable that api thing?

warped wraith
#

you should prob allow API access

#

idk how it works with MPS though

#

check your console

cyan patio
warped wraith
#

first line in the function, just to see if it even runs

cyan patio
#

:Connect(buy, print("Buy"))

warped wraith
#

no no no

#

in the buy function

#

function buy()
print("Function ran")

cyan patio
#

uh

#

wai

#

Market"place"service

#

not MarketPlaceService

warped wraith
#

Marketplace

#

yeah

cyan patio
#

it works

#

i ddint notice that

warped wraith
#

👍

#

always check console first

#

you can enable it in studio by using the 'output' toggle

cyan patio
#

oh ok

cyan patio
#

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