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

On Touched function problem?

Asked by 9 years ago

So heres my script:

MainScript:

local sp = script.Parent.Parent
local blood1 = sp:WaitForChild("Blood1")
local blood2 = sp:WaitForChild("Blood2")
local blood3 = sp:WaitForChild("Blood3")

script.Parent.Touched:connect(function (hit)
game.Workspace.Autopsy:Play()
blood1.Transparency = 0.4
script.Parent.Secondary.Disabled = false
script.Parent.MainScript.Disabled = true
end)

Secondary:

local sp = script.Parent.Parent
local blood1 = sp:WaitForChild("Blood1")
local blood2 = sp:WaitForChild("Blood2")
local blood3 = sp:WaitForChild("Blood3")

if blood1.Transparency == 0.4 then
wait(0.5)
blood2.Transparency = 0.4
wait(0.5)
blood3.Transparency = 0.4
wait(8)
blood1.Transparency = 1
blood2.Transparency = 1
blood3.Transparency = 1
game.Workspace.Autopsy:Stop()
end

The problem: Whenever I enter my game the mainscript runs without me touching the brick that triggers it. And the secondary script won't work for some reason... Help me please?

0
whats the output saying? NinjoOnline 1146 — 9y
0
actually the output doesn't say anything for me Ultralegend 0 — 9y

1 answer

Log in to vote
-1
Answered by 9 years ago

try this in your main script

local sp = script.Parent.Parent
local blood1 = sp:WaitForChild("Blood1")
local blood2 = sp:WaitForChild("Blood2")
local blood3 = sp:WaitForChild("Blood3")

function  OnTouch(part)
game.Workspace.Autopsy:Play()
blood1.Transparency = 0.4
script.Parent.Secondary.Disabled = false
script.Parent.MainScript.Disabled = true
end
script.Parent.Touched:connect(OnTouch)

1
Thanks that helped me :) Ultralegend 0 — 9y
0
Please accept and vote up mrpoliceman2004 20 — 9y
Ad

Answer this question