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

Help With This Key Door Script?

the parent is the tool. This is for a key door, this script allows you to go through the door. But it just won't.

Also it works in Playtest but not Online

bin = script.Parent

function onButton1Down(mouse)
	
	local hit = mouse.Target
	if (hit == nil) then return end
	if (hit.Name == "SilverDoor2") then
	hit.Transparency = 0.8
	hit.CanCollide = false
	wait(2)
	hit.CanCollide = true
	hit.Transparency = 0

	end
end

function onSelected(mouse)
	print("Action Tool Selected")
	
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

bin.Selected:connect(onSelected)

2 answers

bin = script.Parent

function onButton1Down(mouse)

    local hit = mouse.Target
    if (hit == nil) then return end
    if (hit.Player.Name == "SilverDoor2") then
    hit.Transparency = 0.8
    hit.CanCollide = false
    wait(2)
    hit.CanCollide = true
    hit.Transparency = 0

    end
end

function onSelected(mouse)
    print("Action Tool Selected")

    mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

bin.Selected:connect(onSelected)

You use 'hit.Player.Name'

i think the problem is when you put end on 14 and 15,so try removing end

1 comment

0

No, there is two "If"'s there, That's right. also it only works in playtest mode.

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