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

Part of the script doesn't work, help?

Asked by 9 years ago

Alright, this script works sort of, but it doesnt generate a message into the playergui after elseif. Does anyone know why? script:

script.Parent.MouseClick:connect(function(open)
    if script.Parent.Parent.Parent.door.Transparency == 0 and script.Parent.Parent.CanCollide == true then
        script.Parent.Parent.Parent.door.Transparency = 1
        script.Parent.Parent.Parent.door.CanCollide = false
        wait(5)
        script.Parent.Parent.Parent.door.CanCollide = true
        script.Parent.Parent.Parent.door.Transparency = 0
    elseif script.Parent.Parent.Transparency == 1 and script.Parent.Parent.CanCollide == false then
        m = Instance.new("Message", open.PlayerGui)
        m.Name = "Pm"
        m.Text = "This door is already open."
        wait(3)
        m:Destroy()
    end
end)

script > ClickDetector > door ^ Thats whats in workspace.

1 answer

Log in to vote
0
Answered by 9 years ago

Its because when you click the part, and you declare "open", you are meaning the physical person that clicked the part. In short, the open argument is the person in workspace. Somehow, you need to take the persons name, find it in Players, then find their PlayerGui, THEN insert it there.

0
umm if I change this into a local script and use local player, will that work? Operation_Meme 890 — 9y
0
It has nothing to do with localscripts. You gotta use the FindFirstChild(PLAYERSNAME), and so on. adspace44 20 — 9y
Ad

Answer this question