Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Why are the killing parts in my game acting so strangely?

Asked by 9 days ago
Edited 9 days ago

I made a low detailed post on this before, but it wasn't helpful enough so I'm making this one.

Basically I have a game prototype that I'm testing scripts for a game on. It's a round based game, and the objective is to kill every player in an FFA kinda way. Once players are dead they get moved back to the lobby team, and map voting starts again, and the cycle keeps going.

I have three maps currently for players to vote between: Red, blue, and green.

https://gyazo.com/2e4aede465d0ce0b956f9c6ce8e0fdd4 (What the whole thing looks like, the yellow parts inside each map are the killing parts, just for testing how players getting killed would work.)

There's this major bug I noticed that's preventing my game from working:

  1. The red map kill part kills the player and their team gets changed, but their body parts end up getting teleported to the blue map then get flung in one direction

  2. The green map usually works perfectly, kills them and changes their team...

  3. The blue map kills the player, but their team doesn't change and the whole main round script actually ends up stopping.

  4. On some test runs each kill part does the same thing: The kill part doesn't kill the player and there's an error in the output saying "Humanoid is not a valid member of Accessory"

Apart from number 4, there are no errors in the output. Another note is that all the maps are the exact the same, and have the same scripts so I don't know why they act differently. I also do not have any back doors or viruses in the game. Would anyone happen to know why any of this is happening?

Links to the scripts involved:

https://gyazo.com/9f74b12ad5dd027118d95dfe8231aa85 Player death script in StarterPlayerScripts (checks if the player is in-game, then fires a remote event to the following server script to change their team)

https://gyazo.com/7c0ae420f5e7ab61ef873e341b6fb689 Player death script in SSS (gets the remote event from the last script, changes their team and also lowers the number value in ReplicatedStorage holding the number of players alive.)

https://gyazo.com/0ed03f9202cc76feaced8e4cfd360efb Script inside each of the kill parts to kill the player touching it.

Main round cycle script:

wait(5)

local Timer = game.ReplicatedStorage.Timer
local inRound = game.ReplicatedStorage.inRound

while true do
    Timer.Value = "15"

    inRound = false

    for i = 15,0,-1 do
        wait(1)
        Timer.Value = tostring(i)
    end


    local highestVote = 0
    local votes = 0
    local voteTable = {tonumber(game.workspace.VoteCountGui1.SurfaceGui.VoteCount1.Text),tonumber(game.workspace.VoteCountGui2.SurfaceGui.VoteCount2.Text),tonumber(game.workspace.VoteCountGui3.SurfaceGui.VoteCount3.Text)}

    for i, v in pairs(voteTable) do
        if v > votes then
            votes = v
            highestVote = i
        end
    end


    if highestVote == 1 then
        for i, v in pairs(game.Players:GetPlayers()) do
            v.Character.HumanoidRootPart.Position = game.workspace.Map1.Position + Vector3.new(0,5,0)
        end
    elseif highestVote == 2 then
        for i, v in pairs(game.Players:GetPlayers()) do
            v.Character.HumanoidRootPart.Position = game.workspace.Map2.Position + Vector3.new(0,5,0) -- Teleports players to map based on the highest vote.
        end
    else
        for i, v in pairs(game.Players:GetPlayers()) do
        v.Character.HumanoidRootPart.Position = game.workspace.Map3.Position + Vector3.new(0,5,0)
        end
    end


    inRound = true

    for i, v in pairs (game.Players:GetPlayers()) do
        v.Team = game.Teams.Playing
    end

    Timer.Value = "Game Starting!"
    wait(2)
    Timer.Value = "3"
    wait(1)
    Timer.Value = "2"
    wait(1)
    Timer.Value = "1"
    wait(1)
    Timer.Value = "FIGHT!"
    wait(1)
    game.ReplicatedStorage.TimerEnabled:FireAllClients() -- Tells the client's localscript to disable the timer GUI.



    for i, v in pairs(game.Players:GetPlayers()) do
        if v.Team == game.Teams.Playing then
            game.ReplicatedStorage.PlayersAlive.Value = game.ReplicatedStorage.PlayersAlive.Value + 1
        end
    end

    while game.ReplicatedStorage.PlayersAlive.Value > 1 do
        wait(0.1)
    end

    game.ReplicatedStorage.TimerEnabled:FireAllClients()     -- Tells the client's localscript to enable the timer GUI.

    for i, v in pairs(game.Players:GetPlayers()) do
        if v.Team == game.Teams.Playing then
            Timer.Value = (v.DisplayName .. " wins!")
        end
    end

    wait(3)

    for i, v in pairs (game.Players:GetPlayers()) do
        v.Team = game.Teams.Lobby
        v.Character.HumanoidRootPart.Position = game.workspace.LobbyPlate.Position + Vector3.new(0,5,0)
    end


end

Sorry about the long post, but if someone knew about a solution it would be greatly appreciated :)

0
Sorry, but it is impossible to help you with just 3 small sections of your scripts. The only way you could get help is by pasting your scripts using proper foramating. I had a look at the scripts, but you need to show how you teleport players, to try to find out why it works like that sleazel 855 — 9d
0
I edited it to show the main round cycle and how it teleports the players, I didn't actually know about the code formatting before sorry for that... JGBlocky 10 — 9d

Answer this question