So I have this script that detects if a cars driver seat is close to the “gas pump” so its ready to fill up, but its saying “workspace” is not a valid member of datamodel
local Player = game.Players.LocalPlayer
local Character = Player.Character
local mouse = Player:GetMouse()
mouse.Button1Down:Connect(function()
if mouse.Target and mouse.Target.Name == 'GasPump1' and (Player.Character.HumanoidRootPart.Position - mouse.Hit.p).magnitude <= 10 and game.Workspasce((Player.Name.. "Car").Driving.DriverSeat.Position - mouse.Hit.p).magnitude <= 10 then
if mouse.Target.AlreadyOpened.Value == false then -- stop code if it isnt false
game.ReplicatedStorage.GiveGas:FireServer()
end
end
end)
here is the server script(other is local) i dont know if this one works to. I assume not seeing as this one does not work.
local re = Instance.new("RemoteEvent",game.ReplicatedStorage)
re.Name = "SpawnSedan"
re.OnServerEvent:Connect(function(Player)
game.Workspace(Player.. "Car").Driving.DriverSeat.Gas.Value = 50
end)
Facepalm this was one of the issues, but now im getting a new error, saying "Attempt to index field “driving” (a nil value) here is a screenshot of the setup.
local Player = game.Players.LocalPlayer
local Character = Player.Character
local mouse = Player:GetMouse()
mouse.Button1Down:Connect(function()
if mouse.Target and mouse.Target.Name == 'GasPump1' and (Player.Character.HumanoidRootPart.Position - mouse.Hit.p).magnitude <= 10 and (game.Workspace[Player.Name .. "Car"].Driving.DriverSeat.Position - mouse.Hit.p).magnitude <= 10 then
if mouse.Target.AlreadyOpened.Value == false then -- stop code if it isnt false
game.ReplicatedStorage.GiveGas:FireServer()
end
end
end)