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
1local plr = game.Players.LocalPlayer
2local mouse = player:GetMouse()
3local torso = plr:WaitForChild(Torso)
4 
5 
6mouse.KeyDown:connect(function(key)
7if key == "g" then
8    local f = Instance.new("Fire",torso)
9end

2 answers

Log in to vote
2
Answered by 9 years ago

I've to found your errors in this script.

01local plr = game.Players.LocalPlayer
02local mouse = player:GetMouse() -- you need to write it like this:local mouse = plr:GetMouse() because you declare the player as plr.
03--You forgot to declare the character because the torso is not in the plr but in the character.
04local torso = plr:WaitForChild(Torso) --<-- You need to put it in that -->""
05 
06 
07mouse.KeyDown:connect(function(key)--here, you forgot to put an end)
08if key == "g" then
09    local f = Instance.new("Fire",torso)
10end

Code fix here:

01local plr = game.Players.LocalPlayer
02local mouse = plr:GetMouse()
03local character = plr.CharacterAdded:wait() or workspace[plr.Name]
04local torso = character:WaitForChild("Torso")
05 
06 
07mouse.KeyDown:connect(function(key)
08key = key:lower()
09    if key == "g" then
10         local f = Instance.new("Fire",torso)
11    end
12end)
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:

1repeat wait() until plr.Character
2Torso = 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