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

How to enable a script through the touch of a part from a player?

Asked by 6 years ago
Edited 6 years ago

So i have a part in my place that acts as lava and i wanted to make it so when the player steps into the lava the set frames from the screen gui would fade in and out as to make it look like the player is on fire. Heres what i came up to

out1 = script.Parent.outleft
out2 = script.Parent.outtop 
out3 = script.Parent.outright  
out4 = script.Parent.outbottom 
in1 = script.Parent.inleft 
in2 = script.Parent.intop 
in3 = script.Parent.inright 
in4 = script.Parent.inbottom 
lava = workspace.burningLava
local player = game.Players.LocalPlayer
local touch=true

function startburning(part)
    if touch==true then
    if part.Name == "burningLava" then
    for i=1,0.5,-0.1 do
    out1.BackgroundTransparency=i
    out2.BackgroundTransparency=i
    out3.BackgroundTransparency=i
    out4.BackgroundTransparency=i
    wait(0.1)
    end
    for i=1,0.7,-0.1 do
    in1.BackgroundTransparency=i
    in2.BackgroundTransparency=i
    in3.BackgroundTransparency=i
    in4.BackgroundTransparency=i
    wait(0.1)
    end
    end
    touch=false
    end
    end

function endburning(part)
    if touch==false then
    if part.Name == "burningLava" then
    while out1.BackgroundTransparency<=1 do
    out1.BackgroundTransparency=out1.BackgroundTransparency+0.1
    out2.BackgroundTransparency=out2.BackgroundTransparency+0.1
    out3.BackgroundTransparency=out3.BackgroundTransparency+0.1
    out4.BackgroundTransparency=out4.BackgroundTransparency+0.1
    wait(0.1)   
    end
    while in1.BackgroundTransparency<=1 do
    in1.BackgroundTransparency=in1.BackgroundTransparency+0.1
    in2.BackgroundTransparency=in2.BackgroundTransparency+0.1
    in3.BackgroundTransparency=in3.BackgroundTransparency+0.1
    in4.BackgroundTransparency=in4.BackgroundTransparency+0.1
    wait(0.1)   
    end
    end
    touch=true
    end
    end
player.Character.Humanoid.Touched:connect(startburning)
player.Character.Humanoid.TouchEnded:connect(endburning)

For some reason the localscript wont work thou. Pls halp.

0
Instead of doing "out1 = script.Parent.outleft.BackgroundTransparency," do ""out1 = script.Parent.outleft" and then every time you use "out1" do "out1.BackgroundTransparency" UnityAlex 36 — 6y
0
On line 57, TouchEnded is not an event of Humanoid objects. TouchEnded is an event of BasePart objects. Palhairfreak 71 — 6y

Answer this question