now the loadstrings completly dont run anymore
here is the code that runs the loadstrings (after i put in ur code)
local ValueFolder = script.Parent:WaitForChild("ScriptValues")
local character = script.Parent
local plr = game.Players:GetPlayerFromCharacter(character)
local glove = plr.Backpack:GetChildren()[1]
script.Equipped.Event:Connect(function()
local code = ValueFolder.OnEquip.Value
local environment = setmetatable({
print = function(...)
log(tostring(...),'print') -- custom func you can implement
end,
warn = function(...)
log(tostring(...),'warn')
end,
error = function(...)
log(tostring(...),'error')
end,
},{
__index = function(t,k)
return env[k]
end,
})
local func,err = loadstring(code) -- code here
if err then
warn(err)
else
setfenv(func,environment) -- sets the environment of the loadstring, which runs it
end
end)
script.Unequipped.Event:Connect(function()
local code = ValueFolder.OnUnEquip.Value
local environment = setmetatable({
print = function(...)
log(tostring(...),'print') -- custom func you can implement
end,
warn = function(...)
log(tostring(...),'warn')
end,
error = function(...)
log(tostring(...),'error')
end,
},{
__index = function(t,k)
return env[k]
end,
})
local func,err = loadstring(code) -- code here
if err then
warn(err)
else
setfenv(func,environment) -- sets the environment of the loadstring, which runs it
end
end)
script.AbilityButtonPressed.Event:Connect(function()
local code = ValueFolder.OnAbility.Value
local environment = setmetatable({
print = function(...)
log(tostring(...),'print') -- custom func you can implement
end,
warn = function(...)
log(tostring(...),'warn')
end,
error = function(...)
log(tostring(...),'error')
end,
},{
__index = function(t,k)
return env[k]
end,
})
local func,err = loadstring(code) -- code here
if err then
warn(err)
else
setfenv(func,environment) -- sets the environment of the loadstring, which runs it
end
end)
script.OnHit.Event:Connect(function()
local code = ValueFolder.OnHit.Value
local environment = setmetatable({
print = function(...)
log(tostring(...),'print') -- custom func you can implement
end,
warn = function(...)
log(tostring(...),'warn')
end,
error = function(...)
log(tostring(...),'error')
end,
},{
__index = function(t,k)
return env[k]
end,
})
local func,err = loadstring(code) -- code here
if err then
warn(err)
else
setfenv(func,environment) -- sets the environment of the loadstring, which runs it
end
end)