I have been trying to figure this out for 5 days straight, making multiple threads with similar issues.
So, let me explain (again.).
I am trying to make a move that releases a sphere, any NPC or Character parts and decals inside the sphere turn invisible (transparency 1, tweened.) and billboard guis turn to false. It then waits 10 seconds and the parts, decals, billboardguis go visible again. However, apparently my script doesn’t want to do that.
I’ve went through 6 different script rewritings but I can’t seem to fix it.
The way it works, is that I have a tool for doing the move, a remote event and a modulescript to require the move.
Here’s also one problem https://gyazo.com/e2e780addeab685f28ec4692e81da7b5.
Layout of the tool:
The moves script detects if the player using the tool presses a key, and if that key is E then it does the move. The localscript then fires the remote event to find the modulescript for the move, and then finally require that modulescript from the server (so that effects will be serversided).
Moves Localscript
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local Modules = RS:WaitForChild("Modules")
local Fruit = Modules:WaitForChild("Fruit")
local HM = Modules:WaitForChild("Handlers")
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local remote = RS.RemoteEvents.Fruit
local PlayerGui = Player:WaitForChild("PlayerGui")
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Cooldown1 = false
local Holding1 = false
local Cooldown2 = false
local Holding2 = false
local Debounce = 1
local Mouse = Player:GetMouse()
local track1 = Humanoid:LoadAnimation(Tool.Animations.Spin)
local tweeninfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local ts = game:GetService("TweenService")
local function zmove()
Tool.Active.Value = "Z"
remote:FireServer("Suke", "Self Invisibility", "Start")
wait(2)
for i, v in pairs(Character:GetDescendants()) do
if (v.Name ~= "HumanoidRootPart" and v:IsA("MeshPart") or v:IsA("Part") and v.Name ~= "HumanoidRootPart") then
v.Transparency = 0.7
elseif v:IsA("Decal") then
v.Transparency = 0.7
end
end
wait(10)
for i, v in pairs(Character:GetDescendants()) do
if (v.Name ~= "HumanoidRootPart" and v:IsA("MeshPart") or v:IsA("Part") and v.Name ~= "HumanoidRootPart") then
v.Transparency = 0
elseif v:IsA("Decal") then
v.Transparency = 0
end
end
remote:FireServer("Suke", "Self Invisibility", "End")
Tool.Active.Value = "None"
end
local function xmove()
Tool.Active.Value = "X"
remote:FireServer("Suke", "Area Invisibility", "Start")
wait(10)
Tool.Active.Value = "None"
end
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E and Debounce == 1 and Tool.Equip.Value == true and Tool.Active.Value == "None" and Cooldown1 == false then
Debounce = 2
local HIS = Tool.Animations["Area Charge"]
HoldTrack = Player.Character.Humanoid:LoadAnimation(HIS)
HoldTrack:Play()
for i = 1,math.huge do
if Debounce == 2 then
local RootPos, MousePos = Player.Character.HumanoidRootPart.Position, Mouse.Hit.Position
Player.Character.HumanoidRootPart.CFrame = CFrame.new(RootPos, Vector3.new(MousePos.X, RootPos.Y, MousePos.Z))
Player.Character.HumanoidRootPart.Anchored = true
else
break
end
wait()
end
elseif Input.KeyCode == Enum.KeyCode.Z and Tool.Equip.Value == true and Tool.Active.Value == "None" and Cooldown1 == false then
track1:Play()
zmove()
Cooldown1 = true
wait(3)
Cooldown1 = false
end
end)
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E and Debounce == 2 and Tool.Equip.Value == true and Tool.Active.Value == "None" and Cooldown1 == false then
Cooldown1 = true
Debounce = 3
local PIS = Tool.Animations["Area Release"]
local PunchTrack = Player.Character.Humanoid:LoadAnimation(PIS)
PunchTrack:Play()
HoldTrack:Stop()
PunchTrack:GetMarkerReachedSignal("Release"):Connect(function()
xmove()
task.wait(10)
Cooldown1 = false
end)
wait(1)
Player.Character.HumanoidRootPart.Anchored = false
wait(2)
Tool.Active.Value = "None"
wait(0.1)
Debounce = 1
end
end)
Remote Event
local rs = game:GetService("ReplicatedStorage")
local remote = rs.RemoteEvents.Fruit
local modules = rs.Modules
local fruitmodules = modules.Fruit
remote.OnServerEvent:Connect(function(plr, ability, move, functions, option1, option2)
if plr then
for i, k in pairs(fruitmodules:GetChildren()) do
if k.Name == tostring(ability) then
local abilitymove = k[move]
local required = require(abilitymove)
required[functions](plr, option2)
end
end
end
end)
Module Script
local functions = {}
function functions.Start(plr)
local tweeninfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local tweenservice = game:GetService("TweenService")
local chr = plr.Character
local remote = game.ReplicatedStorage.RemoteEvents.Suke.Invisible
local hum = chr:FindFirstChildOfClass("Humanoid")
local health = hum.Health
local cube = script.cube:Clone()
cube.Parent = workspace.Effects
cube.Position = chr.HumanoidRootPart.Position
local tween = tweenservice:Create(cube, tweeninfo, {Size = Vector3.new(50.75, 50.75, 50.75)})
tween:Play()
tween.Completed:Wait()
local function GetTouchingParts(part)
local connection = part.Touched:Connect(function() end)
local results = part:GetTouchingParts()
connection:Disconnect()
return results
end
local debounce = false
local aoe = GetTouchingParts(cube)
local targets = {}
for i, a in pairs(aoe) do
if a:IsDescendantOf(workspace.NPCs) then
local parent = a.Parent
if not table.find(targets, parent) then
for i, p in pairs(parent:GetDescendants()) do
if (p:IsA("BasePart") or p:IsA("Decal") and p.Name ~= "HumanoidRootPart" and p.Transparency ~= 1) then
local tween = tweenservice:Create(p, tweeninfo, {Transparency = 1})
tween:Play()
elseif p:IsA("BillboardGui") then
p.Enabled = false
end
end
end
table.insert(targets, parent)
print("NPC")
wait(10)
if table.find(targets, parent) then
for i, p in pairs(parent:GetDescendants()) do
if (p:IsA("BasePart") or p:IsA("Decal") and p.Name ~= "HumanoidRootPart" and p.Transparency ~= 0) then
local tween = tweenservice:Create(p, tweeninfo, {Transparency = 0})
tween:Play()
elseif p:IsA("BillboardGui") then
p.Enabled = true
end
end
end
elseif a:IsDescendantOf(workspace.Players) then
local parent = a.Parent
local playar = game.Players:GetPlayerFromCharacter(parent)
if not table.find(targets, parent) then
for i, p in pairs(parent:GetDescendants()) do
if (p:IsA("BasePart") or p:IsA("Decal") and p.Name ~= "HumanoidRootPart" and p.Transparency ~= 1) then
local tween = tweenservice:Create(p, tweeninfo, {Transparency = 1})
tween:Play()
remote:InvokeClient(playar, 0.7)
elseif p:IsA("BillboardGui") then
p.Enabled = false
end
end
end
table.insert(targets, parent)
print("Player")
wait(10)
if table.find(targets, parent) then
for i, p in pairs(parent:GetDescendants()) do
if (p:IsA("BasePart") or p:IsA("Decal") and p.Name ~= "HumanoidRootPart" and p.Transparency ~= 0) then
local tween = tweenservice:Create(p, tweeninfo, {Transparency = 0})
tween:Play()
elseif p:IsA("BillboardGui") then
p.Enabled = true
end
end
end
end
end
end
return functions
Here are the scripts. Please help me fix this, it’s been almost a week, 5 days specifically. I do not want this to reach a week to fix, please. Thank you to whoever helps me and finds a way around this…