generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: FilteringEnabled and Touched

Previous Thread :: Next Thread 
Ceranity is not online. Ceranity
Joined: 20 Oct 2010
Total Posts: 945
06 Apr 2016 05:57 AM
I have FilteringEnabled on (I need to), but I can't seem to figure out how to get the server to communicate with the client. I want a server script to InvokeClient() when a brick is touched, however it cannot find the player who touched the brick.

What I want to do is to get the serverscript to find the remotefunction within a player's Gui, but it looks as though that filteringenabled does not allow you to get the player that touched a part. If this is the case, how am I supposed to make the server communicate with the client?

script.Parent.Touched:connect(function(touched)
local check = touched:GetPlayerFromCharacter()
local event = check.PlayerGui.MainGui.BuildingGuis.Restrooms.Walked.Restroom
local brick = script.Parent.Parent.WalkTo
event:InvokeClient(brick)
end)
error = GetPlayerFromCharacter is not a valid member of part

I've tried doing:

script.Parent.Touched:connect(function(player)
local event = player.PlayerGui.MainGui.BuildingGuis.Restrooms.Walked.Restroom
local brick = script.Parent.Parent.WalkTo
event:InvokeClient(brick)
end)

then I get "player is not a valid member of part"

Can anyone help me?

Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
06 Apr 2016 06:01 AM
script.Parent.Touched:connect(function(touched)

touched is the part that has touched the part that triggers this event(sorry if this sounds confusing :/), so let's say you walked on it and your left leg touched it, your "touched" variable is here the left leg, not the character. So you want to replace this line:

local check = touched:GetPlayerFromCharacter()

with this:

local check = touched.Parent:GetPlayerFromCharacter()

because the character is the parent of that left leg that touched the brick.
Report Abuse
Ceranity is not online. Ceranity
Joined: 20 Oct 2010
Total Posts: 945
06 Apr 2016 06:06 AM
Thanks for the reply,

Now it's saying "getplayerfromcharacter() is not a valid member of model"
By model is means the parent of the brick that was touched. FilteringEnabled doesn't allow you to get the player who touched a brick it seems.
Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
06 Apr 2016 06:08 AM
Oh darn, I made a mistake, you don't use it like that :P

You're supposed to do it like this:

local check = game.Players:GetPlayerFromCharacter(touched.Parent)
Report Abuse
Ceranity is not online. Ceranity
Joined: 20 Oct 2010
Total Posts: 945
06 Apr 2016 06:13 AM
Ok so here's what I've done:

script.Parent.Touched:connect(function(touched)
local check = game.Players:GetPlayerFromCharacter(touched.Parent)
local event = check.PlayerGui.MainGui.BuildingGuis.Restrooms.Walked.Restroom
local brick = script.Parent.Parent.WalkTo
event:InvokeClient(brick)
end)

The error has changed somewhat to "attempt to index local 'check' (a nil value)"
Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
06 Apr 2016 06:22 AM
If you start a server on studio with one player in it and you test it like that, maybe you can check on the server side if you can actually see the players?
Report Abuse
Ceranity is not online. Ceranity
Joined: 20 Oct 2010
Total Posts: 945
06 Apr 2016 06:32 AM
Yup, players are there.
Report Abuse
Ceranity is not online. Ceranity
Joined: 20 Oct 2010
Total Posts: 945
06 Apr 2016 07:03 AM
Bump.

This issue is DEFINITELY down to FilteringEnabled, since it works without it checked. There must be some way to use Touched() with it enabled as a majority of front page games do it.
Report Abuse
membra is not online. membra
Joined: 14 Oct 2008
Total Posts: 6313
06 Apr 2016 08:50 AM
GetPlayerFromCharacter will return a player object or nil if there is no player associated with the object in the parameter. Your script always assumes that the object that triggers the event is a player, therefore, ANY part is capable of triggering your event, meaning that if anything other than a player touches the part the 'check' variable will be assigned nil. You could use something like...
if game.Players:GetPlayerFromCharacter(touched.Parent) then
check = game.Players:GetPlayerFromCharacter(touched.Parent)
end


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image