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

How to make a message appear when a person touches a part(door)?

Asked by 9 years ago

How do you make a message appear when a person touches a part. Here is my current script,

local door = game.Workspace.Door
function onTouchM(obj)
    door.Touched:connect(function()
        msg = Instance.new("Message", game.Workspace)
        msg.Text = "..userID..Has Found The Door"
        wait(5)
        msg.Text:Destroy()
    end)
end

Help plz. :) Note: this is a localScript in workspace and not in anything else. It is not in the part(door). Just lying around in workspace.

1 answer

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Well, you kind of messed up on the concatenation and not everything that hits the brick will be a player.

door = game.Workspace.Door
door.Touched:connect(function(hit)
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
        p = game.Players:GetPlayerFromCharacter(hit.Parent)
        m = Instance.new("Message", Workspace)
        m.Text = p.Name.." has found the door."
        wait(5)
        m:Destroy()
    end
end)

~ Thank me by accepting this answer/bumping up my reputation!

Ad

Answer this question