Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Player is not a valid member of DataModel?

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.

1 comment

0

game.Players, not game.Player -_-

2 answers

Line 20 should be local player = game.Players:FindFirstChild("plr") there might be more errors, but thats the immediate fix

3 comments

0

dang it, ninja'd

0

I still have the same problem

0

get shrekt incaspaz

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

2 comments

3

OH MY GODDDDDKJRDLDLEOSJ;DLIHGPHJH0PTRIU LOOK AT LINE 13 OF THE SNIPPET

0

haha like if you cried

This discussion is preserved as it was. New answers, comments, and votes are closed.