I am putting a Message in a players PlayerGui so only they see it when they touch the part...
I think in some way, I need to use GetPlayerFromCharacter
but i'm not sure how to use this with using Instance.new
so here is my script (Not Local)
SP = script.Parent SPP = script.Parent.Parent Debounce = false SP.Touched:connect(function(hit) local Human_Check = hit.Parent:FindFirstChild("Humanoid") if SPP.Enable.Value == false then SP.Transparency = 0.5 wait(0.1) SP.Transparency = 0 local msg = Instance.new("Message"), game.Players.GetPlayerFromCharacter.PlayerGui msg.Text = "Please wait a few seconds and try again" wait(3) msg:remove() end end)
I would like a little lesson on arguments - in the Object Browser and example is GetPlayerFromCharacter(character), the (character) confuses me a bit- if possible. This script is not finishes, so please do not add in my Debounce. Enable is a BooleanValue which is getting activated by another part.
You're on the right track, you do need the GetPlayerFromCharacter method. But the method takes a character as it's arguments and is a method of game.Players..
local SP = script.Parent local SPP = script.Parent.Parent local db = false SP.Touched:connect(function(hit) if db == false then db = true local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then if SPP.Enable.Value == false then SP.Transparency = 0.5 wait(0.1) SP.Transparency = 0 local m = Instance.new('Message',plr.PlayerGui) m.Text = "Please wait a few seconds and try again" wait(3) m:Destroy() end end db = false end end)