|
fe is enabled, no errors
local bin = game.Workspace.Bin.Bin
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
char.Torso.Changed:connect(function()
if (bin.Position - char.Torso.Position).magnitude > 20 then
plr.test.Value = false
for i,v in pairs(plr.PlayerGui:GetChildren()) do
if v.Name == "ClearGui" then
v:Destroy()
end
end
end
end)
end)
end)
gui supposed to close after being 20 studs away from this part |
|
|
Denny9876Join Date: 2012-10-19 Post Count: 117 |
Are you using R15 or R6? If you're using R15, change char.Torso into char.HumanoidRootPart.
If that doesn't work, I don't know. I'm looking through the script to see if anything else is wrong. |
|
|
eRangedJoin Date: 2013-06-15 Post Count: 9746 |
use a remote, u cant see inside PlayerGui with FE |
|
Denny9876Join Date: 2012-10-19 Post Count: 117 |
Is this a localscript or a script? If it's a script, I don't think it works because GUI can only be used by localscripts since FE is enabled.
You'll probably have to use some RemoteEvent stuff. 1 server script which handles when the player gets 20 studs away, and a localscript in StarterGui that does the GUI stuff.
Here's the link to RemoteEvents if you need to learn more about it :
http://wiki.roblox.com/index.php?title=API:Class/RemoteEvent
|
|
|
did i do anyhting wrong (doesnt work)
-- script
local bin = game.Workspace.Bin.Bin
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
char.Torso.Changed:connect(function()
if plr.test.Value == true then
if (bin.Position - char.Torso.Position).magnitude > 20 then
game.ReplicatedStorage:WaitForChild("Destroy"):FireClient(plr)
end
end
end)
end)
end)
-- Localscript
local plr = game.Players.LocalPlayer
function change()
for i,v in pairs(plr.PlayerGui:GetChildren()) do
if v.Name == "ClearGui" then
v:Destroy()
end
plr.test.Value = false
end
end
game.ReplicatedStorage:WaitForChild("Destroy").OnClientEvent:connect(change) |
|
eRangedJoin Date: 2013-06-15 Post Count: 9746 |
use prints to debug ur code and see where it stops |
|
|
i have a high feeling it has to do with the magnitude or .changed but ill try what you said ^ |
|
|
no prints
local bin = game.Workspace:WaitForChild("Bin").Bin
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
print('hello world1')
char.Torso.Changed:connect(function()
print('hello world2')
if plr.test.Value == true then
if (bin.Position - char.Torso.Position).magnitude > 20 then
print('hello world3')
game.ReplicatedStorage:WaitForChild("Destroy"):FireClient(plr)
end
end
end)
end)
end) |
|
|
|
|
i was right magnitude and .changed are the problem |
|
Denny9876Join Date: 2012-10-19 Post Count: 117 |
Wait, are you saying it runs through all the way, or it didn't print anything at all?
If it didn't print anything, it must be that WaitForChild that's stalling it.Make sure there's something named "Bin" in workspace. Also make sure there's nothing else in workspace named "Bin". |
|
|
i put a print after bin afterwards and that worked and nothing after that worked |
|
|
Denny9876Join Date: 2012-10-19 Post Count: 117 |
Put the bin line after char.Torso.Changed.
I think if you use waitforchild before PlayerAdded, the player would have already joined because of waitforchild so game.Players.PlayerAdded won't fire. |
|
|
works in test mode but not in real server rip |
|
Denny9876Join Date: 2012-10-19 Post Count: 117 |
Your script is using GUI stuff and i'm assuming this is a server script. You're probably going to have to use RemoteEvents to fix this one. :I |
|
|