Issues with Integer Value to Character

Having issues getting a server script to clone an Integer Value to a player. Or does that have to be through a local script? Anyways here’s error that’s presently popping up.

image

local Tool = script.Parent
local Event = game:GetService("ReplicatedStorage").JailEvent
local Player = game.Players.LocalPlayer

local Crimes = {
	["Murder"] = {200},
	["Attempted Murder"] = {175},
	["Tresspassing"] = {100},
	["Reckless Driving"] = {85}
}

local BailList = {
	["Murder"] = {500},
	["Attempted Murder"] = {400},
	["Tresspassing"] = {250},
	["Reckless Driving"] = {200}
}

Event.OnServerEvent:connect(function(Player, ...)
	local t = {...}
	if t[1] == "Arrest" and not t[2]:FindFirstChild("Arrested1") then
		local v = Instance.new("IntValue")
		v.Parent = Player
		v.Name = "Arrested1"
		v.Value = 0
		t[2].Arrested1.Value = table.find(Crimes.Murder) --It's breaking here 
		v.Parent = t[2]
		wait(1)
		v:remove()
	elseif t[1] == "UnArrest" then
		if t[2]:FindFirstChild("Arrested") then
			t[2].Arrested1.Value = 0
		end
	end
end)

You’re in a server script, which means game.Players.LocalPlayer is not accessible.

Player is automatically passed in OnServerEvent as the first argument. Delete line 3 where you define Player.

2 Likes

Adding to this, you should name your function parameters instead of using ‘…’. So, for example:

Event.OnServerEvent:connect(function(Player, action, otherPlayer)
    if action == "Arrest" and not otherPlayer:FindFirstChild("Arrested1") then
1 Like