local player = "1BL1ZZARD"
local fruit = "Apple"
if player:IsA("Player") then
print("hi player!")
end
if fruit:IsA("Player") then
print("hi player!")
end
how can i accomplish something like this?
in addition, if it is a player, how can i do something like??
if game:GetService('Players'):FindFirstChild(tostring(fruit), false) then
local plr = game:GetService('Players'):FindFirstChild(tostring(fruit), false)
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:FindFirstChild('Humanoid') or char:WaitForChild('Humanoid', 10)
if (humanoid) then
humanoid.Health = 0
end
plr:Kick('Message')
end
If you’re checking if the variable itself is a reference to a player:
if typeof(var) == "Instance" and var:IsA("Player") then
-- Checks if the variable is an instance, then use the IsA method on it
--...
end
If you’re checking if a variable would lead to a valid player:
local plr = game:GetService("Players"):FindFirstChild(var)
if plr then
-- Check if the plr variable leads to a valid player
-- plr is now a reference to the Player
--...
end
local player = "1BL1ZZARD"
local fruit = "Apple"
local Players = game:GetService("Players") -- Gets the players folder
if i, v in pairs(Players:GetChildren()) do -- Gets everything in the players folder
if v.Name == player then -- Checks for everything with the value of the var "player"
v:Kick("Reason for kick") -- kicks the player
-- v.Humanoid.Health = 0 -- kills the player
print("hi player")
end
end
if i, v in pairs(Players:GetChildren()) do
if v.Name == fruit then
v:Kick("Reason for kick")
-- v.Humanoid.Health = 0
print("hi player")
end
end