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

How may I affect the humanoid in a local script?

Asked by 9 years ago

In my local script found in the PlayerGui how do I affect the humanoid, I want hurt it yet I think it is read only with local scripts.

    local player = game.Players.LocalPlayer
    local Stats = player:WaitForChild("leaderstats")
    local Temp = Stats:WaitForChild("TEMPERATURE")
    local character = player.Character
if not character or not character.Parent then
    character = player.CharacterAdded:wait()
end
    local human = character:findFirstChild("Humanoid")

This is only part of my script but for some reason with my whole script everything works but the damaging Humanoid and the ouput gives me no reason.

Hope someone can asnwer this question.

0
You would want to find the humanoid located inside of the character and call the :TakeDamage() function on it. TakeDamage will not work if the player has a forcefield. If you're using FilterinEnabled, then you will need to use the function in a ServerScript, otherwise it will appear as though you died for no reason to other clients. M39a9am3R 3210 — 9y
0
Alright thank you. SurvivalAptissimum 25 — 9y

1 answer

Log in to vote
0
Answered by
sigve10 94
9 years ago
    local player = game.Players.LocalPlayer
    local Stats = player:WaitForChild("leaderstats")
    local Temp = Stats:WaitForChild("TEMPERATURE")
    local character = player.Character
if not character or not character.Parent then
    character = player.CharacterAdded:wait()
end
    local human = character:findFirstChild("Humanoid")
--[[ I guess that your script is about your character losing health when reaching a certain temperature, so I will make a script for that ]]--
temp = "" -- if you want your temperature changing put something here or whatever...
damage = 0.1 -- Insert the damage you will deal to the player
maxtemp = 0 -- Insert your maximum temperature here
mintemp = 0 -- Insert your minimum temperature here
time = 0.1 -- Insert time between damage
while temp >= maxtemp or temp<= mintemp do 
    human.Health = human.Health - damage
    wait(time)
end
0
sorry for the comment errors. I'm new to scripthelpers and I thought an auto-newline would stop the comment. Remove the [[ and the ]]-- on line 9 sigve10 94 — 9y
0
I understand your idea but the script cannot interact with the Humanoid, it only receives information but cannot affect it, I need to find a way around it. SurvivalAptissimum 25 — 9y
Ad

Answer this question