Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can't damage humanoid In online mode?

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.

1 comment

0

USING BOLD IS LIKE TALKING IN ALL CAPS ALSO YOUR CODE IS MALFORMED DWEEB

1 answer

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

1 comment

0

Still cannot damage it In Online mode :(

This discussion is preserved as it was. New answers, comments, and votes are closed.