local Player = game.Players.LocalPlayer local inUse = false script.Parent:WaitForChild("Handle").Touched:connect(function(hit) local HH = hit.Parent:FindFirstChild("Humanoid") if HH and HH.Parent ~= Player.Character then if not inUse then inUse = true local name = HH.Parent.Name local gui = script.Parent.Arrest:clone() gui.Parent = Player.PlayerGui gui.Draggable.Frame.Value.Value = name gui.Draggable.Frame.TextLabel.Text = "Do you wish to arrest: "..name.."?" gui.Draggable.Frame.Visible = true gui.Draggable.Frame.Confirm.MouseButton1Click:connect(function() print('Arrest',gui.Draggable.Frame.Value.Value, gui.Draggable.Frame.Reason.Text) inUse = false local player = game.Player:FindFirstChild("plr") local arrestplayer = game.Players:GetPlayerFromCharacter(HH.Parent) gui:Destroy() function setTeam(player, teamName) player.TeamColor = game.Teams[teamName].TeamColor if player.Character then --Just in case the character doesn't exist for some reason player.Character:BreakJoints() -- Kills the players' character end end setTeam(game.player.arrestplayer, "Prisoner") end) gui.Draggable.Frame.Cancel.MouseButton1Click:connect(function() inUse = false gui:Destroy() end) end end end) script.Parent.Equipped:connect(function() inUse = false Player.Character.Humanoid.WalkSpeed = 28 end) script.Parent.Unequipped:connect(function() inUse = false Player.Character.Humanoid.WalkSpeed = 16 end)
That is my code, but the errors are saying that Player is not a valid member of DataModel. Error is on the 20th line. I wanted the script to be like, if press confirm(gui), set player prisoner, kill that person. and finish.
Line 20 should be local player = game.Players:FindFirstChild("plr")
there might be more errors, but thats the immediate fix
gui.Draggable.Frame.Confirm.MouseButton1Click:connect(function() print('Arrest',gui.Draggable.Frame.Value.Value, gui.Draggable.Frame.Reason.Text) inUse = false local player = game.Players:FindFirstChild("plr") local arrestplayer = game.Players:GetPlayerFromCharacter(HH.Parent) gui:Destroy() function setTeam(player, teamName) player.TeamColor = game.Teams[teamName].TeamColor if player.Character then --Just in case the character doesn't exist for some reason player.Character:BreakJoints() -- Kills the players' character end end setTeam(game.player.arrestplayer, "Prisoner")
I get the problem at 29th line of the code which is setTeam(game.player.arrestplayer, "Prisoner") Error: player is not a valid member of DataModel