Help, I tried making a script that breaks the enemies leg but when it ends up picking the number then the script says that PlayerGui isn't a valid member of Player
function legbreak()
local legbreak = math.random(1, 3)
if legbreak == 1 then
local chr = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(chr)
print(plr.Name)
wait(RoF)
plr.PlayerGui.GUI.Data.legbroken.Value = true
hit.Humanoid.WalkSpeed = 10
plr.PlayerGui.GUI.HUD.BrokenLeg.Visible = true
print("Yes")
elseif legbreak == 2 then
print("No")
elseif legbreak == 3 then
print("No")
end
end

3 comments
You never made this a Touched event.
You never defined hit in the script. Therefor you should not be getting a character, and that should return nil on the plr variable.
That's not the full script. I'm using a gun script but this is the only part that doesn't work now stop saying I don't have a hit -_-