Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

On Touched function problem?

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?

2 comments

0

whats the output saying?

0

actually the output doesn't say anything for me

1 answer

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)

2 comments

1

Thanks that helped me :)

0

Please accept and vote up

This discussion is preserved as it was. New answers, comments, and votes are closed.