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

Can't damage humanoid In online mode?

Asked by 8 years ago

Ok so, I am making glass that breaks when you shoot it to damage it at all. It works perfectly In Studio but not Online anyone got an idea why?

Script 1 Inside Glass Model

local h = Instance.new("Humanoid")

h.Parent = script.Parent

local Human = script.Parent:WaitForChild("Humanoid")

while true do
    wait(0.01)  
    if script.Parent:FindFirstChild("Humanoid") == true then
    wait(2) 
    script.Parent:FindFirstChild("Humanoid").MaxHealth = 5000
    wait(2)
    script.Parent:FindFirstChild("Humanoid").Health = 5000
    end
end

Script 2 Also Inside Glass Model.

local Destroyed = script.Parent:FindFirstChild("Humanoid")
local sound = script.Parent:FindFirstChild("Boom")
local Human = script.Parent:WaitForChild("Humanoid")

while true do
    wait(0.01)
local Human = script.Parent:WaitForChild("Humanoid")    
    if Destroyed.Health == 0 then
        sound:Play()
        script.Parent:remove()
    end
end********

When I load this up In a Online Server and Shoot it or Use a Melee on it I can not damage it at all and the health never goes down when you attack it. Please help, Thank you. Btw I already tried the Blog Post "It works in Studio, but not online!" That's where the :WaitForChild("Humanoid") came in.

0
USING BOLD IS LIKE TALKING IN ALL CAPS ALSO YOUR CODE IS MALFORMED DWEEB User#6546 35 — 8y

1 answer

Log in to vote
0
Answered by
Scerzy 85
8 years ago

First of all, there isn't much need for the first script because you can just insert a humanoid into the Glass Model within studio and change all the values there. You should probably do that so that you don't have to use all those WaitForChild functions.

Now, with your second script, if I'm not mistaken, you've defined the same variable 3 times. Remove the Destroyed Variable and the second defining of the Human variable and change the script to look like this

local sound = script.Parent:findFirstChild("Boom")
local Human = script.Parent.Humanoid

while true do
    wait(0.01)
    if Humanoid.Health == 0 then
        sound:Play()
        script.Parent:remove()
    end
end

This will only work if you pre-insert the humanoid into the glass model. If you still insist on using the first script for some reason, then the script can be changed to look like this

local sound = script.Parent:findFirstChild("Boom")
local Human = script.Parent:WaitForChild("Humanoid")

while true do
    wait(0.01)
    if Human.Health == 0 then
        sound:Play()
        script.Parent:remove()
    end
end
0
Still cannot damage it In Online mode :( ShadowShocks 42 — 8y
Ad

Answer this question