The issue is that scripts can’t declare the local player (normal scripts), but you can get the player who touched using the touched connection.
For more information about the Touched
connection, see this page.
You’ll have to use another approach.
The issue is that scripts can’t declare the local player (normal scripts), but you can get the player who touched using the touched connection.
For more information about the Touched
connection, see this page.
You’ll have to use another approach.
theres 3 separate cars but the stuff inside is just the same name
I’m telling you your code is only applying to 1 car.
i changed it
local part1 = game.Workspace.CarNPC.Car1.Car1.CarBody1
local part2 = game.Workspace.CarNPC.Car2.Car2CarBody2
local part3 = game.Workspace.CarNPC.Car3.Car3.CarBody3
local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player.PlayerGui
local EndingUI = PlayerGui.EndingUI
part1.Touched:Connect(function()
wait(1)
EndingUI.Enabled = true
EndingUI.TextLabel.Text = "HitByCar"
EndingUI.TextLabel1.Text = "Ending"
end)
part2.Touched:Connect(function()
wait(1)
EndingUI.Enabled = true
EndingUI.TextLabel.Text = "HitByCar"
EndingUI.TextLabel1.Text = "Ending"
end)
part3.Touched:Connect(function()
wait(1)
EndingUI.Enabled = true
EndingUI.TextLabel.Text = "HitByCar"
EndingUI.TextLabel1.Text = "Ending"
end)
i really dont know why this doesnt work its kinda annoying
i gotta go do something for like 6 minutes but if you figure something out please tell me
part2 doesn’t look correct.
Also this code needs to be in a LocalScript, correct?
Alright.
Try this normal script:
local Players = game:GetService("Players")
local Part = script.Parent :: BasePart
Part.Touched:Connect(function(OtherPart)
local Humanoid = OtherPart.Parent and OtherPart.Parent:FindFirstChildWhichIsA("Humanoid")
if not Humanoid then return end
local Player = Players:GetPlayerFromCharacter(Humanoid.Parent)
if Player then
local PlayerGui = Player.PlayerGui
local EndingUI = PlayerGui.EndingUI :: ScreenGui
EndingUI.Enabled = true
EndingUI.TextLabel.Text = "HitByCar"
EndingUI.TextLabel1.Text = "Ending"
end
end)
im back
so replace the old script thats under the part i want to trigger the ending right
IT WORKS TYSM
I spent like 3 hours trying to get this working if there any more buggs ill let you know but so far its working not randomly apearing and works when i hit any of the cars
Just adding some additional information…
Instead of putting this script for every car, you can instead declare all the cars in the workspace and connect their events inside one normal/server-side script.
It would be even better to place this script in the ServerScriptService
.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.