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 9 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

01local h = Instance.new("Humanoid")
02 
03h.Parent = script.Parent
04 
05local Human = script.Parent:WaitForChild("Humanoid")
06 
07while true do
08    wait(0.01
09    if script.Parent:FindFirstChild("Humanoid") == true then
10    wait(2)
11    script.Parent:FindFirstChild("Humanoid").MaxHealth = 5000
12    wait(2)
13    script.Parent:FindFirstChild("Humanoid").Health = 5000
14    end
15end

Script 2 Also Inside Glass Model.

01local Destroyed = script.Parent:FindFirstChild("Humanoid")
02local sound = script.Parent:FindFirstChild("Boom")
03local Human = script.Parent:WaitForChild("Humanoid")
04 
05while true do
06    wait(0.01)
07local Human = script.Parent:WaitForChild("Humanoid")   
08    if Destroyed.Health == 0 then
09        sound:Play()
10        script.Parent:remove()
11    end
12end********

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 — 9y

1 answer

Log in to vote
0
Answered by
Scerzy 85
9 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

01local sound = script.Parent:findFirstChild("Boom")
02local Human = script.Parent.Humanoid
03 
04while true do
05    wait(0.01)
06    if Humanoid.Health == 0 then
07        sound:Play()
08        script.Parent:remove()
09    end
10end

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

01local sound = script.Parent:findFirstChild("Boom")
02local Human = script.Parent:WaitForChild("Humanoid")
03 
04while true do
05    wait(0.01)
06    if Human.Health == 0 then
07        sound:Play()
08        script.Parent:remove()
09    end
10end
0
Still cannot damage it In Online mode :( ShadowShocks 42 — 9y
Ad

Answer this question