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

Help With This Key Door Script?

Asked by
Seenit 80
10 years ago

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

Log in to vote
0
Answered by 10 years ago
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'

Ad
Log in to vote
-1
Answered by 10 years ago

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

0
No, there is two "If"'s there, That's right. also it only works in playtest mode. Seenit 80 — 10y

Answer this question