#Metatable function doesn't work
11 messages · Page 1 of 1 (latest)
What is the problem ?
I might be dumb as fuck, but this is a way to do it
local plr = game.Players.LocalPlayer
local hum = game.Workspace:WaitForChild(plr.Name):FindFirstChild("Humanoid")
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, GPE)
if input.KeyCode == Enum.KeyCode.Q and GPE == false then
hum.WalkSpeed = 69 --bitch
end
end)
im learning about metatables
i need it
like that
Your speed doesn't change ?
local Player = {}
Player.__index = Player
function Player:AdjustSpeed(n)
self.Player.Character.Humanoid.WalkSpeed = n
print("zaza")
end
function Player.new(player)
local NewPlayer = setmetatable({}, Player)
NewPlayer.Player = player
return NewPlayer
end
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, GPE)
if input.KeyCode == Enum.KeyCode.Q then
for _, player in ipairs(game.Players:GetPlayers()) do
local newPlayer = Player.new(player)
newPlayer:AdjustSpeed(69)
print("Changed to 69 walkspeed bitch")
end
end
end)