What do you want to achieve? I want to make so the part will throw the position of where the mouse clicked
What is the issue? It is saying " Hit is not a valid member of CFrame"
What solutions have you tried so far? I tried to use vector3 and CFrame.new and I tried to find any solutions in the hub
Script
local tool = script.Parent
local char = tool.Parent
local handle = script.Parent.Handle
local remote = game.ReplicatedStorage.Lol
local TweenService = game:GetService("TweenService")
local active = script.Parent.Activated1.Value
local eqq = script.Parent.Eqquiped1.Value
local kam = game.Workspace.Kam
remote.OnServerEvent:Connect(function(player, Mouse)
tool.Equipped:Connect(function()
print("Weqq")
local players = game:GetService("Players")
eqq = true
local clone = kam:Clone()
clone.Parent = game.Workspace
clone.Anchored = true
clone.CanCollide = false
clone.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,5,0)
wait(1.5)
local tweenInfo = TweenInfo.new(
2, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
true, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local Goal = {}
Goal.Orientation = clone.Orientation + Vector3.new(0,7200,0)
local Tween = TweenService:Create(clone, tweenInfo, Goal)
Tween:Play()
tool.Activated:Connect(function()
if eqq == true then
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = clone
BodyVelocity.Velocity = Mouse.Hit.lookVector * 110
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
end
end)
end)
tool.Unequipped:Connect(function()
eqq = false
end)
end)
Local script
local tool = script.Parent
local char = tool.Parent
local handle = script.Parent:WaitForChild("Handle")
local player = game.Players.LocalPlayer
local remote = game.ReplicatedStorage.Lol
local mouse = player:GetMouse()
tool.Equipped:Connect(function()
remote:FireServer(mouse.Hit)
end)
use remote:FireServer(mouse) cause you are sending it to the server but on the server you are doing .Hit so if you pass the .Hit you are doing .Hit twice which causes the error so either change the server to not use .Hit or change the client to not send the .Hit
also idk if you can just send the mouse to the server so try this if it doesnt work: remote:FireServer({["Hit"]=mouse.Hit})
I didn’t bother reading the script sorry, your firing mouse over to the server, Mouse doesn’t replicate and can’t be accessed via server even through a remote event (I think) instead you can do:
You did not do it right cause it should have worked… Ill just add it to your full scripts for you
server
local tool = script.Parent
local char = tool.Parent
local handle = script.Parent.Handle
local remote = game.ReplicatedStorage.Lol
local TweenService = game:GetService("TweenService")
local active = script.Parent.Activated1.Value
local eqq = script.Parent.Eqquiped1.Value
local kam = game.Workspace.Kam
remote.OnServerEvent:Connect(function(player, MouseHit)
tool.Equipped:Connect(function()
print("Weqq")
local players = game:GetService("Players")
eqq = true
local clone = kam:Clone()
clone.Parent = game.Workspace
clone.Anchored = true
clone.CanCollide = false
clone.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,5,0)
wait(1.5)
local tweenInfo = TweenInfo.new(
2, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
true, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local Goal = {}
Goal.Orientation = clone.Orientation + Vector3.new(0,7200,0)
local Tween = TweenService:Create(clone, tweenInfo, Goal)
Tween:Play()
tool.Activated:Connect(function()
if eqq == true then
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = clone
BodyVelocity.Velocity = MouseHit.lookVector * 110
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
end
end)
end)
tool.Unequipped:Connect(function()
eqq = false
end)
end)
local
local tool = script.Parent
local char = tool.Parent
local handle = script.Parent:WaitForChild("Handle")
local player = game.Players.LocalPlayer
local remote = game.ReplicatedStorage:WaitForChild("Lol")
local mouse = player:GetMouse()
tool.Equipped:Connect(function()
remote:FireServer(mouse.Hit)
end)
local Equipped = false
local Character = nil
local Player = nil
script.Parent.Equipped:Connect(function()
Character = script.Parent.Parent
Player = game.Players:GetPlayerFromCharacter(Character)
Equipped = true
end)
script.Parent.Unequipped:Connect(function()
Character = nil
Player = nil
Equipped = false
end)
local MousePos = Instance.new("RemoteFunction")
MousePos.Name = "MousePos"
MousePos.Parent = script.Parent
local Projectile = Instance.new("Part")
Projectile.Name = "Projectile"
Projectile.Size = Vector3.new(1, 1, 1)
Projectile.Material = Enum.Material.Neon
Projectile.Color = Color3.fromRGB(255, 0, 0)
script.Parent.Activated:Connect(function()
local MouseHit = MousePos:InvokeClient(Player)
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
local Clone = Projectile:Clone()
Clone.CFrame = HumanoidRootPart.CFrame * CFrame.new(0, 5, 0)
Clone.Parent = workspace
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Velocity = MouseHit.lookVector * 110
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVelocity.Parent = Clone
game:GetService("Debris"):AddItem(Clone, 5)
Clone.Touched:Connect(function(hit)
if hit.Parent == Character then return end
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid:TakeDamage(25)
end
end)
end
end)
Localscript
local MousePos = script.Parent:WaitForChild("MousePos")
local Mouse = game.Players.LocalPlayer:GetMouse()
MousePos.OnClientInvoke = function()
return Mouse.Hit
end