Server refusing to read passed value through event as true

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I’m doing this code to a friend, but for some reason the code stopped working, the server simply refuses to read the passed value as true, dispiting the code being correct

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

--Client:
local PL = game:GetService("Players")
local RP = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")

local Player = PL.LocalPlayer

local Wizard = RP:WaitForChild("Wizard")

local Equip = Wizard:WaitForChild("Equip")

local Debounces = {
	WandEquipped = false,
}

UIS.InputBegan:Connect(function(input,gameprocessedevent)
	if not gameprocessedevent then
		if UIS.KeyboardEnabled then
			if input.KeyCode == Enum.KeyCode.Q then
				print("Pressed Q")
			elseif input.KeyCode == Enum.KeyCode.E then
				if Debounces.WandEquipped == false then
					Debounces.WandEquipped = true

					Equip:FireServer(Debounces.WandEquipped)
				elseif Debounces.WandEquipped == true then
					Debounces.WandEquipped = false

					Equip:FireServer(Debounces.WandEquipped)
				end

			elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
                                print("Mouse 1 Button Down")
			end
		end
	end
end)

--Server
Equip.OnServerEvent:Connect(function(Player,WandEquipped)
	if WandEquipped == true then -- script doesn't gets past this
               --Do stuff
		print("Equipped")
		
	else
		print("Unequipped")
	end
        print(WandEquipped)
end)

Output just prints nothing when I press E, and the second time It prints Unequipped and false

I’m not sure what’s wrong, but you can simplify your code like this

elseif input.KeyCode == Enum.KeyCode.E then
  Debounces.WandEquipped = not Debounces.WandEquipped
  Equip:FireServer(Debounces.WandEquipped)
end

Yeah I’m not sure either, seems like a studio bug

Seems like the issue was with Player. CharacterAdded:Wait() sorry guys

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.