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

[RESOLVED] How can I stop the physics' "Collision Check" from getting in the way?

Asked by
Minifig77 190
9 years ago

I'm making a minigame where players stand in pre-determined positions and jump to avoid a spinner. which will get them out if they touch it. The spin script is fine, but whenever I introduce a Touched event to the bar, it will raise itself above whatever it touches. I disable the script, test it again, and the bar doesn't do it. How can I stop this?

Code:

The spin script:

GameInProgress = script.Parent.GameInProgress
Update = script.Parent.Update
_G.PlayersInGame = {}
_G.AmountOfPlayers = 0

bar = script.Parent.Spinner.Beam
circle = script.Parent.Spinner.Circle
originalPosition = bar.Position

function Spin(Excess)
    Angle = 0
    rep = 0
    for i = 1, 360 do
        bar.Rotation = Vector3.new(0, Angle + rep, 0)
        Angle = Angle + 1
        rep = rep + Excess
        bar.Position = Vector3.new(bar.CFrame.X, bar.CFrame.Y + .0003, bar.CFrame.Z)
        circle.Position = Vector3.new(circle.CFrame.X, circle.CFrame.Y + .0003, circle.CFrame.Z)
        Update.Value = true
        wait(.000000000000000000000000000000000000000000000000000000000000000000000001)
    end
end

function Game()
    GameInProgress2 = script.Parent.GameInProgress.Value
    Rounds = 0
    EX = 0
    while GameInProgress2 == true do
        if 1+1 == 2 then
            if Rounds <= 1 then
                bar.BrickColor = BrickColor.new("Deep orange")
                circle.BrickColor = BrickColor.new("Deep orange")
                Spin(0)
                Rounds = Rounds + 1
            elseif Rounds > 1 then
                bar.BrickColor = BrickColor.new("Navy blue")
                circle.BrickColor = BrickColor.new("Navy blue")
                Spin(EX)
                EX = EX + .1
                Rounds = Rounds + 1
            end
        end
    end
end
Update.Changed:connect(Game)
GameInProgress.Changed:connect(Game)

The kill script:

spawn = script.Parent.Parent.Parent.Spawn
GameInProgress = script.Parent.Parent.Parent.GameInProgress
db = false
--_G.PlayersInGame

function SearchAndRemove(PLAYER)
    for i = 1, #_G.PlayersInGame do
        if PLAYER == _G.PlayersInGame[i] then
            table.remove(_G.PlayersInGame, i)
            return "Done!"
        end
    end
end

function Touch(Person)
    player = game.Players:GetPlayerFromCharacter()
    if player and GameInProgress.Value == true and script.Parent.BrickColor == "Navy blue" and db == false then
        db  = true
        _G.AmountOfPlayers = _G.AmountOfPlayers - 1
        player.Character:MoveTo(Spawn.Position)
        SearchAndRemove(player)
    end
end
script.Parent.Touched:connect(Touch)

The kill script is a direct child of the spinner.

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

In your Spin function, you have it setting the Position of two objects. Have it set their CFrames instead. Setting the CFrame directly ignores the "collision check" effect.

Also, that wait is ridiculous. Either offload the visual to each client and use RenderStepped to get it to flow smoothly, or just use wait(). The intepreter takes longer to read a single line of code than that wait waits.

Ad

Answer this question