Can't get local script to communicate to the server?
Right then, I've got this drive system for a train that i've been working on. It all works fine and dandy. However, it ajust's things like the chuffing sounds for it through the local script, and as a consequence only the driver can hear it. In future i'll be adding things like particle effects as well. What i'm aiming to do is to make it so everyone can hear it and I've read up about remote events and functions but after about a week of confusing myself I've reached the point where i could do with a bit of guidance.
Anyways, here's the code:
02 | vehicle = game.Workspace:FindFirstChild(script.Parent.Train.Value) |
03 | mouse = game.Players.LocalPlayer:GetMouse() |
04 | Chassis = vehicle.Chassis |
05 | reghinge = Chassis.Regulator.HingeConstraint |
06 | regvalue = Chassis.Regulator.Value |
07 | revhinge = Chassis.Reverser.HingeConstraint |
08 | revvalue = Chassis.Reverser.Value |
09 | cutoffhinge = Chassis.Cutoff.HingeConstraint |
10 | cutoffvalue = Chassis.Cutoff.Value |
11 | airbrakehinge = Chassis.AirBrake.HingeConstraint |
12 | airbrakevalue = Chassis.AirBrake.Value |
13 | brakeseat = vehicle.Body.BrakeSeat |
14 | powerseat = vehicle.Body.PowerSeat |
15 | driveseat = vehicle.Body.Seat |
16 | chuff = vehicle.Body.Chimney.Chuff |
20 | if regvalue.Value < 20 then |
21 | reghinge.TargetAngle = reghinge.TargetAngle- 5 |
22 | powerseat.Torque = powerseat.Torque+. 07 |
23 | regvalue.Value = regvalue.Value+ 1 |
24 | chuff.Volume = chuff.Volume+ 0.03 |
31 | if regvalue.Value > 0 then |
32 | reghinge.TargetAngle = reghinge.TargetAngle+ 5 |
33 | powerseat.Torque = powerseat.Torque-. 07 |
34 | regvalue.Value = regvalue.Value- 1 |
35 | chuff.Volume = chuff.Volume- 0.03 |
41 | if revvalue.Value < 1 then |
42 | revhinge.TargetAngle = revhinge.TargetAngle+ 15 |
43 | powerseat.Throttle = powerseat.Throttle+ 1 |
44 | revvalue.Value = revvalue.Value+ 1 |
49 | if revvalue.Value > - 1 then |
50 | revhinge.TargetAngle = revhinge.TargetAngle- 15 |
51 | powerseat.Throttle = powerseat.Throttle- 1 |
52 | revvalue.Value = revvalue.Value- 1 |
57 | if cutoffvalue.Value < 4 then |
58 | cutoffhinge.TargetAngle = cutoffhinge.TargetAngle+ 87 |
59 | powerseat.MaxSpeed = powerseat.MaxSpeed+ 9 |
60 | cutoffvalue.Value = cutoffvalue.Value+ 1 |
65 | if cutoffvalue.Value > 0 then |
66 | cutoffhinge.TargetAngle = cutoffhinge.TargetAngle- 87 |
67 | powerseat.MaxSpeed = powerseat.MaxSpeed- 9 |
68 | cutoffvalue.Value = cutoffvalue.Value- 1 |
73 | if airbrakevalue.Value < 6 then |
74 | airbrakehinge.TargetAngle = airbrakehinge.TargetAngle+ 30 |
75 | brakeseat.Torque = brakeseat.Torque+. 3 |
76 | airbrakevalue.Value = airbrakevalue.Value+ 1 |
81 | if airbrakevalue.Value > 0 then |
82 | airbrakehinge.TargetAngle = airbrakehinge.TargetAngle- 30 |
83 | brakeseat.Torque = brakeseat.Torque-. 3 |
84 | airbrakevalue.Value = airbrakevalue.Value- 1 |
91 | function LeaveSeat(child) |
92 | if child.Name = = "SeatWeld" then |
93 | script.Parent:Destroy() |
98 | mouse.KeyDown:connect(KeyPress) |
99 | script.Parent.Parent.Parent.ChildRemoved:connect(LeaveSeat) |
Any help is very much appreciated!