I’m making a script so that when you touch a ball with the golf club, and you enter a value, the ball moves but this doesn’t give me any error nor does it work.
Code: Script
local Distance = game.StarterGui.ScreenGui.CalcFrame.Distance.Text
local Height = game.StarterGui.ScreenGui.CalcFrame.Height.Text
local Curve = game.StarterGui.ScreenGui.CalcFrame.Curve.Text
club.Handle.Touched:Connect(function(hit)
local golfBall = hit.Parent
if golfBall then
local bv = game.Workspace.Ball.BodyVelocity
game.ReplicatedStorage.DetailsEvent.OnServerEvent:Connect(function()
bv.Velocity = Vector3.new(Distance, Height, Curve)
end)
end
end)
club.Handle.Touched:Connect(function(hit)
local golfBall = hit.Parent
if golfBall then
local bv = game.Workspace.Ball.BodyVelocity
game.ReplicatedStorage.DetailsEvent.OnServerEvent:Connect(function(Distance, Height, Curve)
bv.Velocity = Vector3.new(Distance, Height, Curve)
end)
end
end)
Local Script:
local Distance = script.Parent.Parent.Distance.Text
local Height = script.Parent.Parent.Height.Text
local Curve = script.Parent.Parent.Curve.Text
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.DetailsEvent:FireServer(Distance, Height, Curve)
end)
When you fire the event on the client. Roblox automatically includes a “player” parameter as the first parameter. This tells the server which client/player fired the remote. Review the code sample I posted above it shows that the player parameter isn’t included by you when you fire from the client, but it does show up as the first parameter when handling that event on the server.
well “myPlayer” is something you would need to define. I just added that line to demonstrate why you would use the “player” parameter. In this case it looks like the “myPlayer” variable would hold the player who own the “GolfClub”.
The error indicates the golfClub tool your programming with is still in the backpack. If its in the backpack its not equipped. Could there be more than one tool?