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

Script is not a valid member of Humanoid?

Asked by 3 years ago
Edited 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

When I run the script, I get an error where it says that: humanoid is not a valid member of script

Script:

local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = char.Humanoid

local fire = Instance.new("Fire") -- making fire
fire.Parent = script.Parent -- putting it in the parent
fire.Heat = 10
fire.Size = 4

for i = 1, 100 do
    script.Parent.Players.Humanoid:TakeDamage(0.1) -- making the player take damage
    wait(0.1)
end

fire:Destroy() -- removing the fire and the script
script:Destroy()

Re-edited by JesseSong!

image https://www.linkpicture.com/q/Screenshot-2021-08-04-124957.png

0
i dont know how to make this into lua Guest_player1689 2 — 3y
0
is the script in workspace? iRedStoneCraftYT 0 — 3y
0
no Guest_player1689 2 — 3y
0
Inside a part? iRedStoneCraftYT 0 — 3y
View all comments (19 more)
0
yes Guest_player1689 2 — 3y
0
its inside a model and its a server script Guest_player1689 2 — 3y
0
im not that knoledgeable on lua but i think that if its inside there it wont work so you can try to add a function on the event a player joins iRedStoneCraftYT 0 — 3y
0
inside a server script Guest_player1689 2 — 3y
0
like for example: game.Players.PlayerAdded:Connect(function(player) will create a function called player when the player is added and you can add information into "player" iRedStoneCraftYT 0 — 3y
0
the script is in a server script inside a server script hold on i'm putting a image Guest_player1689 2 — 3y
0
If the script is in serverscript doing script.Parent.Players wont work because they are sort of siblings for lack of a better term iRedStoneCraftYT 0 — 3y
0
what do i do then? move it to server script service? Guest_player1689 2 — 3y
0
how do i fix it? Guest_player1689 2 — 3y
0
No you can maybe move it to Workspace and change "script.Parent" to possibly "script.Parent.Parent" or change it to game.Workspace.Players iRedStoneCraftYT 0 — 3y
0
except im a bit confused where the script really is, where really is the script? iRedStoneCraftYT 0 — 3y
0
i have included a screenshot but which script do i move player damage or the script? Guest_player1689 2 — 3y
0
whats the script called "script" doing for you? iRedStoneCraftYT 0 — 3y
0
If its a serverscript, there is no LocalPlayer JustinWe12 723 — 3y
0
0
the script i making the gaspump explodeable Guest_player1689 2 — 3y
0
check out JesseSong's response and do it iRedStoneCraftYT 0 — 3y
0
ok Guest_player1689 2 — 3y

1 answer

Log in to vote
1
Answered by
JesseSong 3916 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

Problem:

You've already referenced the player, script.Parent You don't need to add script.Parent.Players because the game already knows what you're talking about.

Solution:

To fix this just remove the .Players in the scripts and you're ready to go!

Fixed Script:

local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = char.Humanoid

local fire = Instance.new("Fire") -- making fire
fire.Parent = script.Parent -- putting it in the parent
fire.Heat = 10
fire.Size = 4

for i = 1, 100 do
    script.Parent.Humanoid:TakeDamage(0.1) -- making the player take damage
    wait(0.1)
end

fire:Destroy() -- removing the fire and the script
script:Destroy()

Remember that this has to go in StarterPlayer < StarterCharacterScripts

0
@JustinWel12 it depends on what your doing. They are only useful for storing stuff in the player's character JesseSong 3916 — 3y
0
yeah and the code too JesseSong 3916 — 3y
0
after a few hours of debugging i finally got the script working Guest_player1689 2 — 3y
View all comments (11 more)
0
I'm stuff confused why my script didn't work for you, as it works for me. I think you did something wrong with mine! JesseSong 3916 — 3y
0
is your script in the starter player? Guest_player1689 2 — 3y
0
yes in startercharacterscripts JesseSong 3916 — 3y
0
that's strange why its working for me but not you Guest_player1689 2 — 3y
0
send a screenshot of the code of mine JesseSong 3916 — 3y
0
Because in the code you said to remove the .Players all i added back was .Players and moved the script into the players character Guest_player1689 2 — 3y
0
in script line 1 Guest_player1689 2 — 3y
0
Did you change my script that i wrote or left it? JesseSong 3916 — 3y
0
because if you changed my script, then it won't work (as i changed it for you) JesseSong 3916 — 3y
0
i did not change your script it should work Guest_player1689 2 — 3y
0
then why didn't it work for you. you did JesseSong 3916 — 3y
Ad

Answer this question