So I am trying to make a fishing simulator game, but I need the line that gets created between the water and the rod, but I am stuck at the line from the player's rod, I could only make it so that the line appears between a specific player name, can anyone help me, please. Here is my code:
01 | local tool = game.Players.Anderssc.Backpack.rod |
02 |
03 | local starterRod = game.Players:WaitForChild() |
04 |
05 | tool.Activated:Connect( function () |
06 |
07 | local Rope = Instance.new( "RopeConstraint" , workspace) |
08 | Rope.Attachment 0 = starterRod.Attachment 0 |
09 | Rope.Attachment 1 = game.Workspace.Rope 2. Attachment 1 |
10 | Rope.Visible = true |
11 |
12 | end ) |
Instead of checking for a player outside of the tool, I would put this script in the tool so you wouldn't have to check the player's backpack. I would also put the RodConstraint in the starterRod and not the workspace (For organization). The code should be somewhere along the lines of this:
01 | local tool = script.Parent |
02 |
03 | local starterRod = game.Players:WaitForChild( "starterRod" ) -- Change "starterRod" to whatever the thing you're waiting for's name |
04 |
05 | tool.Activated:Connect( function () |
06 |
07 | local Rope = Instance.new( "RopeConstraint" , starterRod) |
08 | Rope.Attachment 0 = starterRod.Attachment 0 |
09 | Rope.Attachment 1 = game.Workspace.Rope 2. Attachment 1 |
10 | Rope.Visible = true |
11 |
12 | end ) |
Hope I helped! If you've got any questions on anything, just ask me in the comments.