I've tried lots of different things and none of them work.
Here's my code so far
local checkRole = function()
player.GetAll():IsUserGroup("Probation")
end
while checkRole == "Probation" do
player.SetRunSpeed(0)
player.SetWalkSpeed(0)
player.Color(0,0,0,0)
end
Disclaimer #1: The "endwhile..." is a result of some sort of issue and should be "end [Enter Key] while..."
Disclaimer #2: This is my first script
While loops will not work in Gmod LUA and can even break things. You'll need to make a think hook.
Thank You <3
I would suggest you take a look at the Lua Tutorials on the Garry's Mod Wiki. There's a difference between calling functions from the player library such as player.GetAll() and calling methods on an actual player entity.
player.GetAll() also returns a table of all the players, you'd have to loop through the table like this:
for index, ply in pairs( player.GetAll() ) do
if ply:IsUserGroup("Probation") then
-- change properties on ply here
end
end
If you're new to programming outright, it would be helpful to read the beginner tutorials on the page linked above, to find out more about Lua.
hook.Add("Think","ghostBan",function()
for k,v in pairs(player.GetAll()) do
if v: IsUserGroup("Probation") then
player.SetColor(0,0,0,0)
player.Freeze(true)
end
end
end)
This is my newest script. It's detecting the Probation however player.SetColor is returning a nil value now and I'm not sure as to why
When you're using ply:SetColor() do it like this ply:SetColor(Color(0,0,0,0)). Also you might run into a problem with invisibility. To change player's alpha I think you'll need to use
ply:SetRenderMode(RENDERMODE_TRANSALPHA)
Sorry, you need to Log In to post a reply to this thread.