so basicly ive been trying to get the script ive got in ServerScriptService that it effects all part that are tagged with it but now the blocks that are tagged havent gotten any function so i wanted to ask what wrong w this script and how i could fix it so my parts that are tagged work again. this is my script:
local platform = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InRound = ReplicatedStorage:WaitForChild("InRound")
local isTouched = false
local CollectionService = game:GetService("CollectionService")
for _, part in CollectionService:GetTagged("RoundParts") do
local function fade()
if not isTouched then
isTouched = true
for count = 1, 3 do
platform.Transparency = count / 3
task.wait(0.1)
end
platform.CanCollide = false
if InRound.Value == false then
print("Successful")
platform.Transparency = 0
platform.CanCollide = true
end
isTouched = false
end
end
platform.Touched:Connect(fade)
end
if somebody can help me please send me a fixed version of the script! thanks
3 Likes
Never mind ive found my self a solution but ive still gotten problems with my code! so basicly i also wanted if InRound is set to false that all the parts regenerate instantly but in my code it isnt working the line is:
if InRound.Value == false then
print("Successful")
platform.Transparency = 0
platform.CanCollide = true
end
isTouched = false
end
end
platform.Touched:Connect(fade)
end
1 Like
Why not try two different functions instead of one big one?
Try this code and let me know if it worked or not!
local platform = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InRound = ReplicatedStorage:WaitForChild("InRound")
local isTouched = false
local CollectionService = game:GetService("CollectionService")
for _, part in CollectionService:GetTagged("RoundParts") do
local function fade()
if not isTouched then
isTouched = true
for count = 1, 3 do
platform.Transparency = count / 3
task.wait(0.1)
end
platform.CanCollide = false
if InRound.Value == false then
print("Successful")
platform.Transparency = 0
platform.CanCollide = true
end
isTouched = false
end
end
platform.Touched:Connect(fade)
local function resetPart()
if InRound.Value == false then
platform.Transparency = 0
platform.CanCollide = true
end
end
InRound.Changed:Connect(resetPart)
end
there are some mistakes in this code like the lua local platfrom = script.parent
becasue it aint in the parte seperatly but still thank you for helping
1 Like
thank you this script works now and i can finally continue my game!
1 Like
You’re welcome!
Goodluck with your game!
2 Likes
also i have another issue: I wanted to remove the role system but i dont know how to remove it out of the code w u breaking the code:
local intermission = 30
local roundLength = 170
local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status
local playingTeam = game.Teams.Playing
local lobbyTeam = game.Teams.Lobby
inRound.Changed:Connect(function()
if inRound.Value == true then
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
humanRoot.CFrame = game.Workspace.DropGame.RoundSpawn.CFrame
plr.Team = playingTeam
char:WaitForChild("Humanoid").Died:Connect(function()
plr.Team = lobbyTeam
plr.leaderstats.Deaths.Value += 1
end)
end
else
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
humanRoot.CFrame = game.Workspace.Lobby.LobbySpawn.CFrame
plr.Team = lobbyTeam
end
end
end)
local function round()
while true do
local requiredPlayers = 1
repeat
wait(1)
staus.Value = "Atleast ".. requiredPlayers.." players are needed to start a round"
until #game.Players:GetChildren() >= requiredPlayers
inRound.Value = false
for i = intermission, 0, -1 do
staus.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
for i = roundLength, 0, -1 do
staus.Value = "Game will end in "..i.." seconds"
local playing = {}
for i, plr in pairs(game.Players:GetChildren()) do
if plr.Team.Name == "Playing" then
table.insert(playing, plr.Name)
end
end
if #playing == 0 then
staus.Value = "Everyone Has Died"
wait(3)
break
end
if #playing == 1 then
staus.Value = playing[1].." Has Won The Game!"
for i, plr in pairs(game.Players:GetChildren()) do
if playing[1] == plr.name then
plr.leaderstats.Wins.Value += 1
plr.leaderstats.Coins.Value += 20
end
end
wait(3)
break
end
wait(1)
end
wait(3)
end
end
spawn(round)
please give me the fixed code when you help me (also i want that it gives the winner a random amount in between 20 - 100 coins but idk how to do that)
1 Like
I’ve modified your code a little bit based on your request.
I have removed the role system and made it so the user can receive between 20 to 100 coins.
Although i do like helping people where i can, i’m not going to continue spoonfeeding the full code to you.
The random coins could easily be found on google with one search. Try doing some research before asking little questions okay?
That being said, Here is the code which i modified for you.
Feel free to let me know if the code doesn’t work!
local intermission = 30
local roundLength = 170
local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status
inRound.Changed:Connect(function()
if inRound.Value == true then
for _, plr in pairs(game.Players:GetPlayers()) do
local char = plr.Character
local humanRoot = char:FindFirstChild("HumanoidRootPart")
if humanRoot then
humanRoot.CFrame = game.Workspace.DropGame.RoundSpawn.CFrame
end
end
else
for _, plr in pairs(game.Players:GetPlayers()) do
local char = plr.Character
local humanRoot = char:FindFirstChild("HumanoidRootPart")
if humanRoot then
humanRoot.CFrame = game.Workspace.Lobby.LobbySpawn.CFrame
end
end
end
end)
local function round()
while true do
local requiredPlayers = 1
repeat
wait(1)
staus.Value = "At least ".. requiredPlayers.." players are needed to start a round"
until #game.Players:GetPlayers() >= requiredPlayers
inRound.Value = false
for i = intermission, 0, -1 do
staus.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
for i = roundLength, 0, -1 do
staus.Value = "Game will end in "..i.." seconds"
local playing = {}
for _, plr in pairs(game.Players:GetPlayers()) do
if plr.Team == nil then
table.insert(playing, plr)
end
end
if #playing == 0 then
staus.Value = "Everyone Has Died"
wait(3)
break
end
if #playing == 1 then
local winner = playing[1]
staus.Value = winner.Name.." Has Won The Game!"
local randomCoins = math.random(20, 100)
winner.leaderstats.Wins.Value += 1
winner.leaderstats.Coins.Value += randomCoins
wait(3)
break
end
wait(1)
end
wait(3)
end
end
spawn(round)
thank you so much the code is working!
1 Like
You’re welcome!
Don’t forget to mark the thread as solved if this fixed your issue.
Goodluck!
1 Like
Yo so the code you gave my is kinda not working right! So basicly when everyone (exept for 1 person) dies the round will still continue till the timer is over and i wanted the round to end when eveyone has died OR when timer has ended and i dont know how to fix this! (The last code you send me was the one)
1 Like
You’re able to modify the code yourself. With some google searches you can figure this out.
Note that this is really the last spoonfeed i will be giving you. Most of your requests can be found with a google search so make sure to check that first!
That being said, Here is the modified code for a better round ending.
Make sure to learn from this code and not just copy & paste it
Let me know if it doesn’t work!
local intermission = 30
local roundLength = 170
local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status
inRound.Changed:Connect(function()
if inRound.Value == true then
for _, plr in pairs(game.Players:GetPlayers()) do
local char = plr.Character
local humanRoot = char:FindFirstChild("HumanoidRootPart")
if humanRoot then
humanRoot.CFrame = game.Workspace.DropGame.RoundSpawn.CFrame
end
end
else
for _, plr in pairs(game.Players:GetPlayers()) do
local char = plr.Character
local humanRoot = char:FindFirstChild("HumanoidRootPart")
if humanRoot then
humanRoot.CFrame = game.Workspace.Lobby.LobbySpawn.CFrame
end
end
end
end)
local function round()
while true do
local requiredPlayers = 1
repeat
wait(1)
staus.Value = "At least ".. requiredPlayers.." players are needed to start a round"
until #game.Players:GetPlayers() >= requiredPlayers
inRound.Value = false
for i = intermission, 0, -1 do
staus.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
local roundEnded = false
local winningPlayer = nil
for i = roundLength, 0, -1 do
staus.Value = "Game will end in "..i.." seconds"
local playing = {}
for _, plr in pairs(game.Players:GetPlayers()) do
if plr.Team == nil then
table.insert(playing, plr)
end
end
if #playing == 0 then
staus.Value = "Everyone Has Died"
roundEnded = true
break
end
if #playing == 1 then
local winner = playing[1]
staus.Value = winner.Name.." Has Won The Game!"
winningPlayer = winner
roundEnded = true
break
end
wait(1)
end
if not roundEnded then
staus.Value = "The round has ended"
end
if winningPlayer then
-- Player has won the game, Add more code here if you want to.
local randomCoins = math.random(20, 100)
winningPlayer.leaderstats.Wins.Value += 1
winningPlayer.leaderstats.Coins.Value += randomCoins
end
wait(3)
end
end
spawn(round)
1 Like
Thank you for fixing my self but i’ve made some google research and found nothing so i asked you! I’m sorry that it’s written rude somehow but i’m in a hurry of the game i make and its gonna release tomorow! I really appreciate you helping me with this stuff and i want to Thank you for helping me
1 Like
No problem at all man!
Goodluck with the game
1 Like
so it spawns me in but it just says “Everyone has Died” and it should normally say who won it wouled be very nice if you could fix it for me and imma learn code better to not let my code get fixed everytime i need it fixed
1 Like
I’m not fixing the code for you fully.
But i assume you still have no Teams?
The player needs to have no team, If he does have a team he will not be counted as a correct player that can play your minigame.
Maybe do some more debugging like printing the amount of players playing at that time.
1 Like
I can understand your point to not fully fixxing it!
1 Like
You got this! Try some more debugging and i’m sure you will figure out a way!
1 Like
Okay, but should i tell you if i cant find anything or else?
1 Like
Sure, I might be able to give you some tips or help a little bit with small bits.
But don’t expect me to write a full script for you again since you won’t learn anything that way.