我正在使用来自 Roblox 市场的脚本,我对其进行了大量修改。原始版本不再存在于任何游戏的任何地方,而是作为新角色的孩子出现,尽管我没有可以将它放在那里的脚本。为什么会发生这种情况,我该如何解决?我在其他任何地方都没有找到这样的东西。
这是原始脚本:
local mouse = game.Players.LocalPlayer:GetMouse()
local running = false
function getTool()
for _, kid in ipairs(script.Parent:GetChildren()) do
if kid.className == "Tool" then return kid end
end
return nil
end
mouse.KeyDown:connect(function (key) -- Run function
key = string.lower(key)
if string.byte(key) == 48 then
running = true
local keyConnection = mouse.KeyUp:connect(function (key)
if string.byte(key) == 48 then
running = false
end
end)
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (70+(i*2))
wait()
end
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 85
repeat wait () until running == false
keyConnection:disconnect()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (80-(i*2))
wait()
end
end
end)
这是修改后的脚本:
wait(1)
local Player = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local running = false
local startSpeed = 10
local Speed = script.Speed
Speed.Value = 10
local Earnings = script.Earnings
Earnings.Value = 25
local Cash = script.Cash
Cash.Value = 10000
local speedUpCost = script.speedUpCost
speedUpCost.Value = 100
local earnUpCost = script.earnUpCost
earnUpCost.Value = 100
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = Speed.Value
function getTool()
for _, kid in ipairs(script.Parent:GetChildren()) do
if kid.className == "Tool" then return kid end
end
return nil
end
mouse.KeyDown:connect(function (key)
key = string.lower(key)
if string.byte(key) == 48 then
running = true
local keyConnection = mouse.KeyUp:connect(function (key)
if string.byte(key) == 48 then
running = false
end
end)
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = Speed.Value
repeat wait () until running == false
keyConnection:disconnect()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = startSpeed
end
end)
这是我用来将修改后的脚本和其他一些脚本作为新角色的子代的代码:(这些其他脚本不包括我修改的原始脚本)
function onPlayerEntered(player)
player.CharacterAdded:connect(function (char)
local Scripts = script:GetChildren()
for i=1,5 do
local s = Scripts[i]:clone()
s.Parent = char
s.Disabled = false
end
end)
end
game.Players.PlayerAdded:connect(onPlayerEntered)