I mean I should have known this was going to happen. I have 2 scripts that talk to each other via remote event and create a ball where the player’s mouse position is. I wanted it to like shoo out wherever the mouse is facing.
What’s happening:
robloxapp-20220206-0943497.wmv (661.6 KB)
Local script, located inside the tool:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local event = game.ReplicatedStorage.throw
local canshoot = true
local tool = script.Parent
function OnActivation()
local hit = mouse.Hit
if canshoot == true then
canshoot = false
print('Activation works')
event:FireServer(hit)
wait()
canshoot = true
end
end
tool.Activated:Connect(OnActivation)
Server script, located in serverscriptservice:
local storage = game.ReplicatedStorage
local event = storage.throw
local function onActivation(player, hit)
local ball = Instance.new("Part")
ball.Shape = Enum.PartType.Ball
ball.Color = Color3.new(0.133333, 0.133333, 0.133333)
ball.Size = Vector3.new(2,2,2)
ball.Material = Enum.Material.Grass
ball.CanCollide = false
ball.CFrame = hit
ball.Parent = game.Workspace
local Velocity = Instance.new("BodyVelocity")
Velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
Velocity.Velocity = ball.CFrame.lookVector * 30
Velocity.Parent = ball
end
event.OnServerEvent:Connect(onActivation)