I’m trying to pass information to the server when the player is reloading but the isReloading
variable is equal to the player’s instance when it’s supposed to be a boolean value. I keep getting this error in the console: attempt to concatenate string with Instance
. I figured out that it was passing the player’s instance instead of isReloading because if I do print(isReloading.Name)
it will print my username. How can I get this to pass isReloading as true/false?
Here is a simplified version of my scripts:
Local Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local function Reload()
local isReloading = true
Remotes.Reloading:FireServer(Player, isReloading)
end
Server Script:
local Client = script.Parent.Parent.Parent.Parent -- ugly I know
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local debounce = false
Remotes.Reloading.OnServerEvent:Connect(function(Player, isReloading)
if Client.Name == Player.Name then
if debounce == true then
print(Player.Name.." Reloading: "..isReloading)
task.wait(2)
debounce = false
end
end
end)