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

Why can't a parent be something that a part touches?

Asked by 3 years ago
local banana = game.Workspace.banana
function addFire (touch)
    local fire = Instance.new("Fire")
    fire.Size = 5
    fire.Parent = banana.Touched
end
banana.Touched:Connect(addFire)

I'm new too scripting so I decided to learn about events. I started exploring on my own and wondered why this code won't work.

0
fire.Parent = touch Ziffixture 6913 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I changed your script a little bit!

Here it is:

local banana = game.Workspace.banana
function addFire (touch)
    local fire = Instance.new("Fire")
    fire.Size = 5
    fire.Parent = touch
end
banana.Touched:Connect(addFire)

Hope It Help!

0
Thanks it worked. raahatu 6 — 3y
0
But I have another question: How does the part know if a player touches it or a brick touches it? raahatu 6 — 3y
0
You can use if hit.Parent:FindFirstChild("Humanoid") for all entities, or game.Players:FindFirstChild(hit.Parent.Name) or something like that thecelestialcube 123 — 3y
0
I was following one of Alvin Blox's tutorials and I ended up using the GetPlayerFromCharacter function like this: if game.Players:GetPlayerFromCharacter(touch.Parent) then raahatu 6 — 3y
Ad

Answer this question