So im working on a 2d platforming game. Currently I have been working on enemies and have created this script:
local function onPartTouch(otherPart)
local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if player then
if script.Parent.Active.Value == true then
print ("hi")
script.Parent.Active.Value = false
script.Parent.Parent.Killed.Suspended.Value = true
if player.Character.PoweredUp.Value == true then
player.PoweredUp.Value = false
player.FullHealth = true
print ("FullHealth True")
end
elseif player.Character.FullHealth.Value == true then
player.FullHealth.Value = false
player.HalfHealth.Value = true
print("HalfHealth true")
end
elseif player.Character.HalfHealth == true then
player.Head.CanCollide = false
player.Torso.CanCollide = false
print ("you oofed lol")
end
wait(3)
script.Parent.Active.Value = true
script.Parent.Parent.Killed.Suspended.Value = true
end
script.Parent.Touched:Connect(onPartTouch)
The enemy is supposed to work like in a mario game. If you have a power up (PoweredUp) then you loose that but can still take two more hits before getting killed
so just some basic stuff about the script real quick.
I believe the part of the script that isn't working is after this part of it:
if player.Character.PoweredUp.Value == true then
player.PoweredUp.Value = false
player.FullHealth = true
print ("FullHealth True")
end
elseif player.Character.FullHealth.Value == true then
player.FullHealth.Value = false
player.HalfHealth.Value = true
print("HalfHealth true")
end
elseif player.Character.HalfHealth == true then
player.Head.CanCollide = false
player.Torso.CanCollide = false
print ("you oofed lol")
When I touch the part, it prints the "hi" but none of the other stuff. PoweredUp, FullHealth, and HalfHealth are all BoolValues. These are all in the player's character model. I think this is where I am going wrong, but I don't know for sure. Any help would be greatly appreciated.
Update: Script is working now, you guys are life savers. After going through and looking through some of the script more carefully I found that I had also dropped a few .Values, so that also was breaking it.

1 comment
if it doesn't error then they're all in the right place