So , i'm making a move in a Roblox Name who is activated when you press the "C" Key . This move launch Ball very fast . Its like a fireball . The thing is that i dont know how to launch the fireball in the direction of my mouse , where my mouse is aiming .I know that i need to transfer value of the localscript with the remote but i tried with Mouse.Hit.p and it say nil value in the normal script so i dont kow how to fix that :c If u know answer me :) Thx
make a remote function in server script service --make sure its a function for this example well call it "MouseData"
this will be in a server script
local plr = --player that you want data from local MouseX,MouseY = game.ReplicatedStorage.MouseData:InvokeClient(plr)
in a local script
local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() game.ReplicatedStorage.MouseData.OnClientEvent:Connect(function() return mouse.X,mouse.Y end)
So, I actually have a basketball that uses a similar function to what you're talking about. Let me show you through the code that I have.
--LocalScript local UIS = game:GetService("UserInputService") - get the UIS local RS = game:GetService("ReplicatedStorage") local Event = RS:WaitForChild("Fireball") local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local Character = Player.Character repeat wait() until Character -- Helps to find Player's Character local Humanoid = Character:WaitForChild("Humanoid") --Find Humanoid UIS.InputBegan:Connect(function(input, gameProcessed) if not gameProcessed then --Basically if they not typing if input.KeyCode == Enum.Keycode.C then Event:FireServer(humanoid, Mouse.Hit.p) end end end)
Basically what I'm doing here is firing the humanoid to the server in order to get TargetPoint.
--Server Script local RS = game:GetService("ReplicatedStorage") local Event = RS:WaitForChild("Fireball") local Debounce = true --Make sure it doesn't fire the fireball super fast all the time Event.OnServerEvent:Connect(function(Player, Humanoid, Position) if Player and Humanoid and Position and Humanoid.Parent and game.Players:GetPlayerFromCharacter(Humanoid.Parent) == Player then if Debounce == true then Debounce = false Humanoid.TargetPoint = Position --Do Stuff (Basically make the fireball go to that position) FireballPart.Position = Position wait(2) Debounce = true end end end)
I don't know if this works entirely, but I did implement it to the best of my abilities. Anybody else can help me lol.