I keep getting this error when I try to call local function

I am making a JoJo’s Bizarre Adventure of game and when I use the local function, I get this same error every time
(ServerScriptService.Abilities.Humanoid.R6.Skills.Summon:22: attempt to index boolean with ‘Character’)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Modules = ReplicatedStorage.Modules
local Remotes = ReplicatedStorage.Remotes

local StandRemotes = Remotes.Abilities.R6
local SummonRemote = Remotes.Abilities.R6.Summon

local Effects = ReplicatedStorage.Effects
local Sounds = ReplicatedStorage.Sounds
local Animations = ReplicatedStorage.Animations


local StandSounds = Sounds.Abilities.R6
local PlayerAnimations = Animations.Abilities.R6.Player
local StandAnimations = Animations.Abilities.R6.Stand

local Models = ServerStorage.Models

local StandModel = Models.Abilities.Humanoid.R6
local function Summon(Player)
	local Character = Player.Character
	if not Character then
		return
	end

	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

	local Stand = StandModel:Clone()
	local StandRoot = Stand.PrimaryPart

	StandRoot.CFrame = HumanoidRootPart.CFrame * CFrame.new(2, -1, -2)

	local Weld = Instance.new("Weld")
	Weld.Part0 = HumanoidRootPart
	Weld.Part1 = StandRoot
	Weld.C1 = CFrame.new(2, -1, -2)
	Weld.Parent = HumanoidRootPart

	Stand.Parent = Character
end


SummonRemote.OnServerEvent:Connect(function(Debounce, Player)
	print("Working Checked")
	Summon(Player)
end)

image_2024-07-11_223426176

The Player is always the first argument for OnServerEvent.

trying replacing

SummonRemote.OnServerEvent:Connect(function(Debounce, Player)
	print("Working Checked")
	Summon(Player)
end)

With this:

SummonRemote.OnServerEvent:Connect(function(Player, Debounce)	
    print("Working Checked")
	Summon(Player)
end)

Player is always the first argument

This isn’t my issue but im curious as to why its always the first argument.

The server needs to know which player fired it as it can’t access a specific player like a local script. How will it know which player to affect if you don’t pass the argument? That’s why it has the highest priority as a parameter and needs to come first

1 Like

Thanks for the help you guys, it worked!

1 Like