Hey!
I have a script that detects when a user enters or exits a zone. I am using the module ZonePlus v3.2.0. The script I have fires a remote event to clone the tools scripts from replicated storage and parent them to the tool if the player is within the zone, and the script destroys the scripts within the tool if the player is not within a zone. The tool will not clone or destroy at all for some reason. I have tried troubleshooting with prints as well.
SERVER SCRIPT:
local WS = game:GetService("Workspace")
local RS = game:GetService("ReplicatedStorage")
local eventEnabled = RS:WaitForChild("EnableGK")
local eventDisabled = RS:WaitForChild("DisableGK")
local ZoneModule = require(script:WaitForChild("Zone"))
local union = WS:WaitForChild("Map"):WaitForChild("GoaliePartOrange")
local zone = ZoneModule.new(union)
local team = game:GetService("Teams"):WaitForChild("GKA")
local tool = RS:WaitForChild("GK")
zone.playerEntered:Connect(function(player)
eventEnabled:FireClient(player)
print("Fired Entered")
end)
zone.playerExited:Connect(function(player)
eventDisabled:FireClient(player)
print("Fired Exit")
end)
LOCAL SCRIPT INSIDE THE TOOL:
local RS = game:GetService("ReplicatedStorage")
local val = RS:WaitForChild("GKValue")
local eventEnabled = RS:WaitForChild("EnableGK")
local eventDisabled = RS:WaitForChild("DisableGK")
local tool = script.Parent
local F = tool:WaitForChild("F")
local C = tool:WaitForChild("C")
local E = tool:WaitForChild("E")
local H = tool:WaitForChild("H")
local Q = tool:WaitForChild("Q")
local R = tool:WaitForChild("R")
local T = tool:WaitForChild("T")
local V = tool:WaitForChild("V")
local Z = tool:WaitForChild("Z")
local FClone = RS:WaitForChild("F")
local CClone = RS:WaitForChild("C")
local EClone = RS:WaitForChild("E")
local HClone = RS:WaitForChild("H")
local QClone = RS:WaitForChild("Q")
local RClone = RS:WaitForChild("R")
local TClone = RS:WaitForChild("T")
local VClone = RS:WaitForChild("V")
local ZClone = RS:WaitForChild("Z")
eventDisabled.OnClientEvent:Connect(function()
if F == true then F:Destroy() end
if C == true then C:Destroy() end
if E == true then E:Destroy() end
if H == true then H:Destroy() end
if Q == true then Q:Destroy() end
if R == true then R:Destroy() end
if T == true then T:Destroy() end
if V == true then V:Destroy() end
if Z == true then Z:Destroy() end
print("Sucsess, destroyed!")
eventEnabled.OnClientEvent:Connect(function()
if F == nil then FClone:Clone().Parent = tool
if C == nil then CClone:Clone().Parent = tool
if E == nil then EClone:Clone().Parent = tool
if H == nil then CClone:Clone().Parent = tool
if Q == nil then QClone:Clone().Parent = tool
if R == nil then RClone:Clone().Parent = tool
if T == nil then TClone:Clone().Parent = tool
if V == nil then VClone:Clone().Parent = tool
if Z == nil then ZClone:Clone().Parent = tool
print("Sucsess, cloned!")
end
end
end
end
end
end
end
end
end
end)
end)
Any help would be appriciated, thanks!