Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to toggle script from local script?

how can i make Attack Script Fire from Basic attack local script

https://gyazo.com/e61718e40c6dd2d97fe9290724c2fa35

heres the script if it can help

local Sound1 = script.Parent.WaterSound1
local Sound4 = script.Parent.WaterSound4
local Sound3 = script.Parent.WaterSound3
local Debris = game:GetService("Debris")

local function RemoveEffect(Ep,Tbr,Len,GSize,GCFrame,GTrans)
	spawn(function()
		wait(Tbr)
		TweenService:Create(Ep,TweenInfo.new(Len,Enum.EasingStyle.Linear),			{Transparency = GTrans,Size = GSize,CFrame = GCFrame}):Play()
		Debris:AddItem(Ep,Len+0.5)
	end)
end


local player = game.Players.LocalPlayer

local char = player.Character

local rp = char:WaitForChild("HumanoidRootPart")

local ReplicatedStorage= game:GetService("ReplicatedStorage")
TweenService = game:GetService("TweenService")


local WaterWheelEffects = ReplicatedStorage:WaitForChild("WaterWheel")
local plr = game.Players.LocalPlayer

local Char = plr.Character or plr.CharacterAddeed:Wait()
local Player = game.Players.LocalPlayer

local Character = Player.Character or script.Parent
local Humanoid = Character.Humanoid
local UserInputService = game:GetService("UserInputService")

local AnimationID = 'rbxassetid://4906842204'
local key = 'R'
local debounce = true

UserInputService.InputBegan:Connect(function(Input, IsTyping)

	if  IsTyping then return 

end

	if Input.KeyCode == Enum.KeyCode[key] and debounce == true then
		debounce = false
		local Animation = Instance.new("Animation")
		Animation.AnimationId = AnimationID
		local LoadAnimation = Humanoid:LoadAnimation(Animation)
		LoadAnimation:play()
	local Tool = script.Parent
	local Blade = Tool:WaitForChild("Blade")
	local Trail = Blade:WaitForChild("Trail")
	Trail.Enabled = true

	local player = game:GetService("Players").LocalPlayer
	local Character = player.Character or player.CharacterAdded:Wait()
	local RootPart = Character.HumanoidRootPart
	plr.Character.Humanoid.WalkSpeed = 0
	local BV = Instance.new("BodyVelocity")
	BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	BV.Velocity = RootPart.CFrame.lookVector.Unit * 65 --

	Sound1:Play()
	Sound4:Play()
	spawn(function()
			local WW = ReplicatedStorage:WaitForChild("WaterWheel"):Clone()
			WW.Size = Vector3.new(10.1,10.1,5.1)
			WW.Transparency = 0
			WW.Anchored = true
			WW.CanCollide = false
				wait(0.77)
			WW.CFrame = rp.CFrame * CFrame.Angles(5,1.5,0)
			WW.Parent = workspace
			TweenService:Create(WW,TweenInfo.new(0.25,Enum.EasingStyle.Linear),{Size = Vector3.new(23.44, 26.943, 1.834),Transparency = 0.5,CFrame = rp.CFrame * 	CFrame.Angles(10,1.5,0)}):Play()
			RemoveEffect(WW,0.3,0.25,Vector3.new(0.1,0.1,0.1),rp.CFrame * 	CFrame.Angles(10,1.5,0),1)
			
			Sound3:Play()
	
		end)		
			
	BV.Parent = RootPart

	wait(1)



	Trail.Enabled = false


	BV:Destroy()

debounce = true
plr.Character.Humanoid.WalkSpeed = 16
	wait(2)
		Sound1:Stop()
	Sound4:Stop()
	end
end)

3 comments

0

moe

0

Well, are you gonna make us fix your code from entirely 99 lines?

0

well

1 answer

✓ Accepted answer

I haven't quite worked with using tools yet, but I do know that if you want a LocalScript to fire a function on a Script, RemoteEvents are the answer! Insert a RemoteEvent into your game's ReplicatedStorage, then add this at the top of you LocalScript and at the top of your Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

Now, your scripts should look more like this:

--LocalScript:
local ReplicatedStorage= game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local Sound1 = script.Parent.WaterSound1
local Sound4 = script.Parent.WaterSound4
local Sound3 = script.Parent.WaterSound3
local Debris = game:GetService("Debris")


local player = game.Players.LocalPlayer

local char = player.Character

local rp = char:WaitForChild("HumanoidRootPart")


local WaterWheelEffects = ReplicatedStorage:WaitForChild("WaterWheel")
local plr = game.Players.LocalPlayer

local Char = plr.Character or plr.CharacterAddeed:Wait()
local Player = game.Players.LocalPlayer

local Character = Player.Character or script.Parent
local Humanoid = Character.Humanoid
local UserInputService = game:GetService("UserInputService")

local AnimationID = 'rbxassetid://4906842204'
local key = 'R'
local debounce = true

UserInputService.InputBegan:Connect(function(Input, IsTyping)

    if  IsTyping then return 

end

    if Input.KeyCode == Enum.KeyCode[key] and debounce == true then
	  debounce = false
          RemoteEvent:FireServer(AnimationID, Sound1, Sound4, Sound3)
    end
end)




--Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
TweenService = game:GetService("TweenService")

local function RemoveEffect(Ep,Tbr,Len,GSize,GCFrame,GTrans)
    spawn(function()
        wait(Tbr)
        TweenService:Create(Ep,TweenInfo.new(Len,Enum.EasingStyle.Linear),          {Transparency = GTrans,Size = GSize,CFrame = GCFrame}):Play()
        Debris:AddItem(Ep,Len+0.5)
    end)
end

RemoteEvent.OnServerEvent:Connect(function(player, AnimationID, Sound1, Sound4, Sound3)
        local Animation = Instance.new("Animation")
        Animation.AnimationId = AnimationID
        local LoadAnimation = Humanoid:LoadAnimation(Animation)
        LoadAnimation:play()
	local Tool = script.Parent
	local Blade = Tool:WaitForChild("Blade")
	local Trail = Blade:WaitForChild("Trail")
	Trail.Enabled = true

    local Character = player.Character or player.CharacterAdded:Wait()
    local RootPart = Character.HumanoidRootPart
    plr.Character.Humanoid.WalkSpeed = 0
    local BV = Instance.new("BodyVelocity")
    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = RootPart.CFrame.lookVector.Unit * 65 --

    Sound1:Play()
    Sound4:Play()
    spawn(function()
            local WW = ReplicatedStorage:WaitForChild("WaterWheel"):Clone()
            WW.Size = Vector3.new(10.1,10.1,5.1)
            WW.Transparency = 0
            WW.Anchored = true
            WW.CanCollide = false
                wait(0.77)
            WW.CFrame = rp.CFrame * CFrame.Angles(5,1.5,0)
            WW.Parent = workspace
            TweenService:Create(WW,TweenInfo.new(0.25,Enum.EasingStyle.Linear),{Size = Vector3.new(23.44, 26.943, 1.834),Transparency = 0.5,CFrame = rp.CFrame *    CFrame.Angles(10,1.5,0)}):Play()
            RemoveEffect(WW,0.3,0.25,Vector3.new(0.1,0.1,0.1),rp.CFrame *   CFrame.Angles(10,1.5,0),1)

            Sound3:Play()

        end)        

    BV.Parent = RootPart

    wait(1)



    Trail.Enabled = false


    BV:Destroy()

debounce = true
plr.Character.Humanoid.WalkSpeed = 16
    wait(2)
        Sound1:Stop()
    Sound4:Stop()
end)

Let me know if this worked for you! This is my first time on ScriptingHelpers as an actual helper, so I look forward to helping more of you out when I can :D

2 comments

0

hey dude thank you so much for helping me out altho i have some problems https://gyazo.com/ede86adb140679588797882dd3d8b001 and https://gyazo.com/743cc9cacc42c127c20d0e40c8569926 i fixed other errors but idk

0

i still marked answered cus you put so much effort in it xd

This discussion is preserved as it was. New answers, comments, and votes are closed.