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

Help So that a Player doesn't get killed in my car crash system?

Asked by 4 years ago

I have a block on a model that when it is hit by another car the other car falls apart, I use :BreakJoints() for this so if a player gets hit they die. I was trying to make it so that if the player gets hit they don't die but instead the humanoid sits and the crash sound still plays but the player doesn't die. I'm new to scripting so i cant get that advanced however my code was kinda getting confusing to understand as well. Just please tell me if you can help because the game is just a fun game to mess around in by crashing brick built cars and I want to be able to crash into my friends too and see how much fun me and my friends can have. So if you can help thanks.

function crash(hit) if hit.name ~= "Humaoid" then hit:BreakJoints() script.Parent.Crash:Play()

    if hit.Name == "Humanoid" then
        local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
        if humanoid then            
        humanoid.Sit = true
        script.Parent.Crash:Play()
        wait(5)
        humanoid.Sit = false
        end
        end

end

end script.Parent.Touched:Connect(crash)

The crash part of the script works just fine, just wanted to see if I could make it so players wouldn't die.

0
You can increase the health of the humanoid to around a 100 and after the car has crashed, set it back to 100. SilentsReplacement 468 — 4y
0
BreakJoints() does not care how much health does a humanoid have. alexfinger21 341 — 4y
0
Oh lol i forgot SilentsReplacement 468 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Hello! This should help.


if hit.Parent:FindFirstChild("Humanoid") then local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid") game.ReplicatedStorage.Event:FireServer()--Name of your RemoteEvent script.Parent.Crash:Play() end -- Serverscript game.ReplicatedStorage.Event.OnServerEvent:Connect(function(plr) plr.Character.Humanoid.Sit = true wait(5) plr.Character.Humanoid.Sit = false end)

Hope this helps! You problem: You can’t hit a humanoid. So, I just check if that object has a humanoid.

0
Hello Alex, It solves the character dying however the character doesn't sit I use R15 that might be why. But the in properties of the Humanoid Sit doesn't change to true? EyeDontLie 2 — 4y
0
Hmm, are you using a local script? alexfinger21 341 — 4y
0
Oh, you are. You have to create a remote vent. alexfinger21 341 — 4y
0
Event*. alexfinger21 341 — 4y
0
Here, I will apply edits into my script. alexfinger21 341 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
    if hit.Name == "Humanoid" then
        local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
        if humanoid then
        humanoid.Health = 1000 -- Set it to 1000 or more            
        humanoid.Sit = true
        script.Parent.Crash:Play()
        wait(5)
        humanoid.Health = 100 -- Set it back to default
        humanoid.Sit = false
        end
        end

end

Try this, what this script does that it sets the player health to around 1000, and after 5 seconds, it sets it back to 100. Tell me if there any errors.

0
It doesn't work because I have to use breakjoints() because thats the easiest way to break bricks on a model. The Character still dies. I Just want to find a way that if there is a humanoid it doesn't break joints and makes the player sit.  So if you have any ideas on how to do that please help with that. EyeDontLie 2 — 4y

Answer this question