I am using a Remote Event and calling from local script.
LOCAL SCRIPT local repstore = game:WaitForChild("ReplicatedStorage") local Remote = repstore:WaitForChild("SmokeFlyStart")
Player = game.Players.LocalPlayer Mouse = Player:GetMouse()
cool = true
Mouse.KeyDown:Connect(function(key)
key = key:lower()
if key == "r" then
if cool ~= true then return end
cool = false
Remote:FireServer(Mouse.Hit.p) wait(5) cool = true
end
end)
PROBLEM IN SCRIPT
for i = 1,200 do wait() char.HumanoidRootPart.CFrame = CFrame.new(char.HumanoidRootPart.Position,HOW WOULD I GET MOUSE.HIT.P in this script) BV.Velocity = char.HumanoidRootPart.CFrame.lookVector*60 end
You fired the server with the right value you just never actually make a function serverside to "intercept" it.
Before I start you should not be using mouse.KeyDown as it is deprecated, heres a useful guide on how to use the 2 new methods.
Local
local repstore = game:WaitForChild("ReplicatedStorage") local Remote = repstore:WaitForChild("SmokeFlyStart") Player = game.Players.LocalPlayer Mouse = Player:GetMouse() cool = true Mouse.KeyDown:Connect(function(key) key = key:lower() if key == "r" then if cool ~= true then return end cool = false Remote:FireServer(Mouse.Hit.p) wait(5) cool = true end end)
We are going to use a thing called "OnServerEvent"
Server
game:WaitForChild("ReplicatedStorage"):WaitForChild("SmokeFlyStart").OnServerEvent:Conncet(function(mouseval) for i = 1,200 do wait() char.HumanoidRootPart.CFrame = CFrame.new(mouseval.X,mouseval.Y,mouseval.Z) BV.Velocity = char.HumanoidRootPart.CFrame.lookVector*60 end end)
local repstore = game:WaitForChild("ReplicatedStorage") local Remote = repstore:WaitForChild("SmokeFlyStart")
Remote.OnServerEvent:Connect(function(player)
local char = player.Character
for i, v in pairs (char:GetChildren()) do if v.ClassName == "Part" or v.ClassName == "MeshPart" then v.Transparency = 1 end end local Smoke = game.Lighting.Smoke:Clone() Smoke.Parent = char.HumanoidRootPart local BV = Instance.new("BodyVelocity",char.HumanoidRootPart) BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge) for i = 1,200 do wait() char.HumanoidRootPart.CFrame = CFrame.new(mouseval.X,mouseval.Y,mouseval.Z) BV.Velocity = char.HumanoidRootPart.CFrame.lookVector*60 end for i, v in pairs (char:GetChildren()) do if v.ClassName == "Part" or v.ClassName == "MeshPart" then if v.Name ~= "HumanoidRootPart" then v.Transparency = 0 end end Smoke:Destroy() BV:Destroy() end
end)
using mouseval I got this error ServerScriptService.SmokeFly:23: attempt to index global 'mouseval'(a nil value)