Script is running, Even when the player doesnt have the correct class

  1. Im trying to create a script that will fire an event if the player has the correct class, The class is a string value and this has worked in the past,

  2. The issue is that the script fires the event even if the player doesn’t have the correct class, I have made sure already that there are no typos and there aren’t any errors in the output

You need to change the conditional check.

if game.Players.LocalPlayer.Class.Value == "KingofHell" or game.Players.LocalPlayer.Class.Value == "Demon" then

Like this.

Demon isn’t defined
Should be

game.Players.LocalPlayer.Class.Value == "Demon"

Plus I recommend you returning gameprocess
actually you’re better off just copying and pasting.

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(Input, gameprocess)
	if gameprocess then return end
	if Input.KeyCode == Enum.KeyCode.H then
		if game.Players.LocalPlayer.Class.Value == "KingofHell" or game.Players.LocalPlayer.Class.Value == "Demon" then
			local target = game.Players.LocalPlayer:GetMouse().Target
			game:ReplicatedStorage.KingofHell.FireBlast:FireServer(target)
		end
	end
end)

You might not care but you shouldn’t do client checks doing it from the server is better. ← I mean more secure…

local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Mouse = player:GetMouse()
local FireBlast = ReplicatedStorage.KingofHell.FireBlast

UserInputService.InputBegan:Connect(function(Input, GameProcess)
    if Input.KeyCode == Enum.KeyCode.H and not GameProcess then
        if table.find({"KingofHell", "Demon"}, Player.Class.Value) then
            FireBlast:FireServer(Mouse.Target)
        end
    end
end)

we can fix this by using table.find(), which can make the code easier to read

I also added some variables to make the code readable