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!

01Door = script.Parent
02------------------------------------
03modelname="Taxi Driver"
04------------------------------------
05 
06function onTouched(hit)
07        print("Door Hit")
08        local human = hit.Parent:FindFirstChild("Humanoid")
09        local message = Instance.new("Message")
10        message.Parent = game.Players:playerFromCharacter(hit.Parent)
11        if (human ~= nil ) then
12                if game.Players:playerFromCharacter(hit.Parent).TeamColor==game.Teams:findFirstChild(modelname).TeamColor then
13                        Door.Transparency = 1
14                        wait(1)
15                        Door.CanCollide = false
View all 31 lines...
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.

01Door = script.Parent
02------------------------------------
03modelname="Taxi Driver"
04------------------------------------
05 
06function onTouched(hit)
07        print("Door Hit")
08        local human = hit.Parent:FindFirstChild("Humanoid")
09        local message = Instance.new("Message")
10        message.Parent = game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui
11        if (human ~= nil ) then
12                if game.Players:playerFromCharacter(hit.Parent).TeamColor==game.Teams:findFirstChild(modelname).TeamColor then
13                        Door.Transparency = 1
14                        wait(1)
15                        Door.CanCollide = false
View all 31 lines...
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)

01local Door = script.Parent
02 
03debounce = false
04 
05local modelname="Taxi Driver"
06 
07function onTouched(hit)
08        print("Door Hit")
09        local human = hit.Parent:FindFirstChild("Humanoid")
10       local message = Instance.new("Message", game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui)
11        if (human ~= nil ) and (debounce == false) then
12if game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor==game.Teams:FindFirstChild(modelname).TeamColor then
13            debounce = true
14                        Door.Transparency = 1
15                        wait(1)
View all 29 lines...

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