I have a tool in replicatedstorage that goes in the player’s backpack when they purchase the item and 2 scripts that are supposed to make the ball throw when the player clicks but they dont work.
This is the ball tool in replicatedstorage
This is the localscript inside:
-- Client --
local mouse = game.Players.LocalPlayer:GetMouse()
local remote = game.ReplicatedStorage.RemoteEvent
local tool = script.Parent
tool.Activated:Connect(function()
remote:FireServer(mouse.Hit)
end)
and this is the server script in serverscriptservice
-- Server --
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function(player, mouseHit)
if not player.Character:FindFirstChild("Beach Ball") then return end
local BeachBall = game.ReplicatedStorage["Beach Ball"]:Clone()
BeachBall.Parent = workspace
BeachBall.Position = player.Character["Beach Ball"].Handle.Position
BeachBall.AssemblyLinearVelocity = (mouseHit.p - player.Character.Head.Position).unit * 350
game:GetService("Debris"):AddItem(BeachBall, 10)
end)
Can someone help with this?
Try this:
– Client –
local mouse = game.Players.LocalPlayer:GetMouse()
local remote = game.ReplicatedStorage.RemoteEvent
local tool = script.Parent
tool.Activated:Connect(function()
remote:FireServer(mouse.Hit.Position, tool)
end)
– Server –
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function(plr, pos, tool)
if tool and plr.Character and tool.Parent == plr.Character then
local head = plr.Character:FindFirstChild(“Head”)
if head then
local BeachBall = game.ReplicatedStorage[“Beach Ball”]:Clone()
BeachBall.Parent = workspace
BeachBall.Position = tool.Handle.Position
BeachBall.AssemblyLinearVelocity = (pos - head.Position).unit * 350
game:GetService(“Debris”):AddItem(BeachBall, 10)
end
end
end)
1 Like
i tried but it still didnt work
Try this:
Only change rewrite the quotation marks
–Client–
local plr = game.Players.LocalPlayer
local remote = game.ReplicatedStorage.RemoteEvent
local mouse = plr:GetMouse()
local tool = script.Parent
local equip = false
mouse.Button1Down:Connect(function()
remote:FireServer(mouse.Hit.Position, tool)
end)
plr.Backpack.ChildAdded:Connect(function(child)
if child == tool then
equip = false
end
end)
plr.Backpack.ChildRemoved:Connect(function(child)
if child == tool then
equip = true
end
end)
–Server–
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function(plr, pos, tool)
if tool and plr.Character and tool.Parent == plr.Character then
local head = plr.Character:FindFirstChild(“Head”)
if head then
local BeachBall = game.ReplicatedStorage[“Beach Ball”]:Clone()
BeachBall.Parent = workspace
BeachBall.Position = tool.Handle.Position
BeachBall.AssemblyLinearVelocity = (pos - head.Position).unit * 350
game:GetService(“Debris”):AddItem(BeachBall, 10)
end
end
end)
it still didn’t work and I changed the quotes too
im going to check that rn
30char
no error
I might just find a ball tutorial on YouTube and edit it to suit my needs for the beach ball if I can’t figure it out