Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How To Charge With FilteringEnabled?

Asked by
Ruves 21
4 years ago

I'm trying to make it so while the mouse is down my ability starts charging and then when released will activate, my problem is how would I execute this with FilteringEnabled? I've been able to do it without but how would I pass through the charging value to expand the size of a part gradually as the mouse is held?

3 answers

Log in to vote
2
Answered by 4 years ago

When you click MouseButton1, fire a Remote Event/Function. You could either pass it with an argument to see if they are holding down or let go (true or false). On InputEnded, fire either the same Remote (with false or whatever you set as parameter) or a different one. Then you can use a NumberValue as an iterator for growing it, then handle it on the server.

https://developer.roblox.com/en-us/api-reference/class/UserInputService

Also, please provide some code or proof that you tried next time.

Ad
Log in to vote
0
Answered by
nc2r 117
4 years ago
Tool.Activated:Connect(function()StartCharging:FireServer()end)
Tool.Deactivated:Connect(function()DoAbility:FireServer()end)
Log in to vote
0
Answered by
Ruves 21
4 years ago

So far I've got this

LocalScript

local UserInputService = game:GetService("UserInputService")

local Held = false

UserInputService.InputBegan:Connect(function(inputObject)
    if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
        Held = true
        game.ReplicatedStorage["Magic"]["Charging"]:FireServer(true)
    end
end)

UserInputService.InputEnded:Connect(function(inputObject)
    if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
        Held = false
        game.ReplicatedStorage["Magic"]["Charging"]:FireServer(false)
    end
end)

ServerScript

game.ReplicatedStorage["Magic"]["Charging"].OnServerEvent:Connect(function(player, Held)

    while wait(.1) do
        if Held == true then
            print("held")
        end
    end

end)

My only problem is it keeps firing when I release the key, it doesn't seem to be passing through false but I'm not getting any errors.

Answer this question