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

how to set a torso on fire?

Asked by 9 years ago
local plr = game.Players.LocalPlayer
local mouse = player:GetMouse()
local torso = plr:WaitForChild(Torso)


mouse.KeyDown:connect(function(key)
if key == "g" then
    local f = Instance.new("Fire",torso)
end

2 answers

Log in to vote
2
Answered by 9 years ago

I've to found your errors in this script.

local plr = game.Players.LocalPlayer
local mouse = player:GetMouse() -- you need to write it like this:local mouse = plr:GetMouse() because you declare the player as plr.
--You forgot to declare the character because the torso is not in the plr but in the character.
local torso = plr:WaitForChild(Torso) --<-- You need to put it in that -->""


mouse.KeyDown:connect(function(key)--here, you forgot to put an end)
if key == "g" then
    local f = Instance.new("Fire",torso)
end


Code fix here:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local character = plr.CharacterAdded:wait() or workspace[plr.Name]
local torso = character:WaitForChild("Torso")


mouse.KeyDown:connect(function(key)
key = key:lower()
    if key == "g" then
         local f = Instance.new("Fire",torso)
    end
end)

Ad
Log in to vote
0
Answered by
funyun 958 Moderation Voter
9 years ago

Torso is not a direct child of Player. Wait for the character like so:

repeat wait() until plr.Character
Torso = plr.Character:WaitForChild("Torso")
0
This gets inserted were..? xlaser23 60 — 9y
0
It shows you how to get the torso. Insert it wherever it's relevant. Perci1 4988 — 9y

Answer this question