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

So, what did I do wrong here?

Asked by 8 years ago
Edited 8 years ago

Okay, so I have a wall that only allows certain teams to enter. I want the script to pop a message if the other team goes and touches the wall. The killing of the the other team works, and the transparency and everything works, but the message does not. Can someone help me with this? I only want the message going to that one person who was trying to go through that door/wall

Thanks here is what i have!

Door = script.Parent 
------------------------------------
modelname="Taxi Driver"
------------------------------------

function onTouched(hit) 
        print("Door Hit") 
        local human = hit.Parent:FindFirstChild("Humanoid") 
        local message = Instance.new("Message")
        message.Parent = game.Players:playerFromCharacter(hit.Parent)
        if (human ~= nil ) then
                if game.Players:playerFromCharacter(hit.Parent).TeamColor==game.Teams:findFirstChild(modelname).TeamColor then
                        Door.Transparency = 1
                        wait(1) 
                        Door.CanCollide = false 
                        Door.Transparency = 1 

                else
                        human.Health = 0 
                        message.Text = "Player was not a Taxi Driver" 
                        wait(5) 
                        message:Remove ()

                end

        end 
end 

connection = Door.Touched:connect(onTouched)

local debounce = false

0
Sublime tabbing there mate. User#11440 120 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

You're putting the message inside of Player. It needs to go inside of PlayerGui.

Door = script.Parent 
------------------------------------
modelname="Taxi Driver"
------------------------------------

function onTouched(hit) 
        print("Door Hit") 
        local human = hit.Parent:FindFirstChild("Humanoid") 
        local message = Instance.new("Message")
        message.Parent = game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui
        if (human ~= nil ) then
                if game.Players:playerFromCharacter(hit.Parent).TeamColor==game.Teams:findFirstChild(modelname).TeamColor then
                        Door.Transparency = 1
                        wait(1) 
                        Door.CanCollide = false 
                        Door.Transparency = 1 

                else
                        human.Health = 0 
                        message.Text = "Player was not a Taxi Driver" 
                        wait(5) 
                        message:Remove ()

                end

        end 
end 

connection = Door.Touched:connect(onTouched)

local debounce = false

Ad
Log in to vote
1
Answered by
itsJooJoo 195
8 years ago
Edited 8 years ago

Problem

The message is not showing up.

Solution

You put the message in the player. You should put it in the PlayerGui to be client-sided.

Suggestions

playerFromCharacter is deprecated, meaning it is unfavorable but still fully functional., use GetPlayerFromCharacter. Also, remove the "connection" variable and just keep it as Door.Touched:connect(onTouched). :findFirstChild was changed to capitalize to :FindFirstChild. Local variables are also in favor to stop lag. You can also parent a new instance by adding it, like this: Instance.new("Part", workspace). And the debounce is not there in the beginning so I'll fix that. This is all very outdated.

Final Script (w/ Suggestions)

local Door = script.Parent 

debounce = false

local modelname="Taxi Driver"

function onTouched(hit) 
        print("Door Hit") 
        local human = hit.Parent:FindFirstChild("Humanoid") 
       local message = Instance.new("Message", game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui)
        if (human ~= nil ) and (debounce == false) then
if game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor==game.Teams:FindFirstChild(modelname).TeamColor then
            debounce = true
                        Door.Transparency = 1
                        wait(1) 
                        Door.CanCollide = false 
                        Door.Transparency = 1 
                else
                        human.Health = 0 
                        message.Text = "Player was not a Taxi Driver" 
                        wait(5) 
                        message:Remove()
                end
        end 
end 

Door.Touched:connect(onTouched)

debounce = false

Remember if this helped, give me a thumbs up and hit that accept button! It helps us both!

0
Thank you, but by score wont let me give you a thumbs up sorry hurricanedog 0 — 8y

Answer this question