Hi!
So I’ve made some river rapids. This script uses Zone Plus by Nanoblox. It’s a great resource. The only problem is my inability to script well.
I’m sure you can notice that’ I’ve got a baisc knowledge of things, but all of the functions are seperate, and I’ll have to make an entry and exit function for all of the individual segments.
I’m wondering if there’s a way to shorten this, or have a universal ‘ExitZone’ function for all of the zones included?
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local ZoneController = require(game:GetService("ReplicatedStorage").Zone.ZoneController)
local container4 = workspace.RapidsD
local container5 = workspace.RapidsE
local container6 = workspace.RapidsF
local container7 = workspace.RapidsG
local zoned = Zone.new(container4)
local zonee = Zone.new(container5)
local zonef = Zone.new(container6)
local zoneg = Zone.new(container7)
zoned.playerEntered:Connect(function(plr)
for _,v in pairs(plr.Character:GetChildren()) do
if plr.Character.HumanoidRootPart:FindFirstChild("Current")==nil then
local b = Instance.new("BodyForce")
b.Parent = plr.Character.HumanoidRootPart
b.force = Vector3.new(1000, 0, -500)
b.Name = "Current"
b.ApplyAtCenterOfMass = true
end
end
end)
zonee.playerEntered:Connect(function(plr)
for _,v in pairs(plr.Character:GetChildren()) do
if plr.Character.HumanoidRootPart:FindFirstChild("Current")==nil then
local b = Instance.new("BodyForce")
b.Parent = plr.Character.HumanoidRootPart
b.force = Vector3.new(1000, 0, 0)
b.Name = "Current"
b.ApplyAtCenterOfMass = true
end
end
end)
zonef.playerEntered:Connect(function(plr)
for _,v in pairs(plr.Character:GetChildren()) do
if plr.Character.HumanoidRootPart:FindFirstChild("Current")==nil then
local b = Instance.new("BodyForce")
b.Parent = plr.Character.HumanoidRootPart
b.force = Vector3.new(0, 0, 1000)
b.Name = "Current"
b.ApplyAtCenterOfMass = true
end
end
end)
zoneg.playerEntered:Connect(function(plr)
for _,v in pairs(plr.Character:GetChildren()) do
if plr.Character.HumanoidRootPart:FindFirstChild("Current")==nil then
local b = Instance.new("BodyForce")
b.Parent = plr.Character.HumanoidRootPart
b.force = Vector3.new(1000, 0, 0)
b.Name = "Current"
b.ApplyAtCenterOfMass = true
end
end
end)
zoned.playerExited:Connect(function(plr)
for _,v in pairs(plr.Character:GetChildren()) do
if plr.Character.HumanoidRootPart:FindFirstChild("Current") then
plr.Character.HumanoidRootPart.Current:Destroy()
end
end
end)
zonee.playerExited:Connect(function(plr)
for _,v in pairs(plr.Character:GetChildren()) do
if plr.Character.HumanoidRootPart:FindFirstChild("Current") then
plr.Character.HumanoidRootPart.Current:Destroy()
end
end
end)
zonef.playerExited:Connect(function(plr)
for _,v in pairs(plr.Character:GetChildren()) do
if plr.Character.HumanoidRootPart:FindFirstChild("Current") then
plr.Character.HumanoidRootPart.Current:Destroy()
end
end
end)
zoneg.playerExited:Connect(function(plr)
for _,v in pairs(plr.Character:GetChildren()) do
if plr.Character.HumanoidRootPart:FindFirstChild("Current") then
plr.Character.HumanoidRootPart.Current:Destroy()
end
end
end)