Hello! I am beginning to learn about Module Scripts. Right now, I am using a local script to detect when the player clicks a seat to fire a function in a module script which seats the player in the seat. My problem is that I do not know how to make the player sit in the clicked seat. Right now on line four of my module script, I have it addressing a specific seat in the workspace whereas it would be ideal so that the player would sit in any clicked seat without needing to do game.Workspace.Model.Seat . How would I change line four?
Local Script:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local testFunctions = require(game.ReplicatedStorage:WaitForChild("ModuleScript"))
mouse.Button1Down:Connect(function()
if mouse.Target and mouse.Target.Parent and (game.Workspace[player.Name].HumanoidRootPart.Position - mouse.Target.Position).magnitude < 8 then
testFunctions.Clicked(player,mouse.Target.Name)
end
end)
Module Script:
local testFunctions = {}
function testFunctions.Clicked(plr, partName)
game.Workspace.Model[partName].Seat:Sit(game.Workspace[plr.Name].Humanoid)
end
return testFunctions
