I need help of any programer, to create a script to can play a VFX with only press any key.
Example: I need press any key and after a few seconds, play a VFX.
I will wait for respond the community
Hello, and welcome to our community.
Here is an example of how this can be done.
You can create a script that will utilize the playerJoinedEvent so that you can tap into the bindingPressedEvent of the player when they are in the game.
-- Custom
local propBasicExplosionVFX = script:GetCustomProperty("BasicExplosionVFX") -- This is a custom property (Asset Reference) added to this script which is used to define the desired VFX to use
function OnBindingPressed(player, binding)
if binding == "ability_extra_33" then -- "ability_extra_33" is the F key on the keyboard
Task.Wait(2) -- Waits 2 seconds before continuing through the function
local playerPos = player:GetWorldPosition() -- Gets the current player position
local explosionObject = World.SpawnAsset(propBasicExplosionVFX, {position = playerPos}) -- Spawns the pre-defined VFX into the world at the player position (This can be changed to wherever you would like to play the VFX
explosionObject.lifeSpan = 3 -- Sets the lifespan of the VFX so that it does not remain in the game forever
explosionObject:Play() -- Actually plays the VFX
end
end
function OnPlayerJoined(player)
player.bindingPressedEvent:Connect(OnBindingPressed) -- Checks when the player presses any key in the game
end
Game.playerJoinedEvent:Connect(OnPlayerJoined) -- Checks when the player joins the game
And here is a screenshot of the hierarchy:
This is a rough example of how this can be done via script. You can make adjustments to fit your own needs. Please let me know if you need any more help
Thank you so much for the help, exactly what I needed. now I can use it for what I need.
Don't you know how to make the equipment that you have on also have it after loading another map?
I have 2 different worlds and I want the team that I have in one, also have it in the other.
I've been around 20-30 days trying to do it.