Hello!
I have three scripts.
In my first script I fired the server by using…
PartTouchRemote:FireServer(Players)
Which I am pretty sure works fine, but tell me if anything is wrong.
In my second script I waited for the Remote event to fire by using…
PartTouchRemote.OnServerEvent(Players)
But then in the Output it says…
16:51:39.806 ServerScriptService.TeleportLorenOnPlayerJoin:11: attempt to call a RBXScriptSignal value - Server - TeleportLorenOnPlayerJoin:11
In my third script the same error pops up using this line of code
PartTouchRemote.OnServerEvent(Players)
16:51:39.737 Workspace. .ManequinBehavior:5: attempt to call a RBXScriptSignal value - Server - ManequinBehavior:5
Any Solutions
Full Scripts:
First Script: Which fires the remote event
-- Locating NPC
local Loren = game.Workspace:FindFirstChild("Loren") -- Can change name (Change variable name, name in brackets and name of NPC)
local Proxpromt = Loren.ProximityPrompt
local MoveLock = game.Players.LocalPlayer.PlayerScripts.MovementLock.Movement
Proxpromt.Enabled = true
MoveLock.Value = true -- true = you can't move. false == you can move
-- Locating Gui
local Dialogue = script.Parent.DialogueBox.TextLabel
local Screen = script.Parent
Screen.Enabled = false
-- Locating Sound
local Sound = script.Parent["PS talk sound"] -- Un comment out if you want sound
-- Dialogue Script
Proxpromt.Triggered:Connect(function() -- Activates NPC ProximityPrompt is triggered
local Players = game:GetService("Players")
local DoorValue = workspace.Build.Door.DoorDestroyValue
Proxpromt.Enabled = false
Screen.Enabled = true -- Enables Screen Gui
Sound:Play() -- Un comment out if you want sound
-- Text(can change)
Dialogue.Text = "Hi! I see you are new to Masked Manequins!"
wait(2.5)-- Duration between lines
Sound:Stop()
wait(1)
Sound:Play()
Dialogue.Text = "I am Loren, I am not actually a Manequin like the others. "
wait(3)
Sound:Stop()
wait(1)
Sound:Play()
Dialogue.Text = "Well you see, I am a human just like you."
wait(2)
Sound:Stop()
wait(1)
Sound:Play()
Dialogue.Text = "I stumbled acro- Wait wait wait. I am here to teach you how to play the game, not ramble about my backstory."
wait(3.5)
Sound:Stop()
wait(1)
Sound:Play()
Dialogue.Text = "Ok first, move forward and around the wall behind me."
wait(2.5)
MoveLock.Value = false
Sound:Stop()
Screen.Enabled = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PartTouchRemote = ReplicatedStorage.PartTouch
local PartTouchValue = ReplicatedStorage:WaitForChild("PartTouchValue")
local part = workspace.Build.TouchPart
PartTouchValue.Value = false
local function onTouch(hit)
local character = hit.Parent
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
PartTouchValue.Value = true
end
end
part.Touched:Connect(onTouch)
while true do
task.wait(.5)
if PartTouchValue.Value then
print("Continued")
PartTouchRemote:FireServer(Players) -- The line that fires the remote event
break
else
print("Part not touched")
end
end
Screen.Enabled = true
Sound:Play()
Dialogue.Text = "You see the manequin infront of you." -------
MoveLock.Value = true
wait(1.5)
Sound:Stop()
wait(1)
Sound:Play()
Dialogue.Text = "Keep staring at it"
wait(1)
Sound:Stop()
wait(1)
Sound:Play()
Dialogue.Text = "If you look away, then it will follow you, if you stare at it, it will stand still."
wait(3)
Sound:Stop()
wait(1)
Sound:Play()
Dialogue.Text = "And... If it touches you, well... It won't end well. I'll keep it at that"
wait(3)
Sound:Stop()
wait(1)
Sound:Play()
Dialogue.Text = "Ok, while looking at the manequin, go find the key which belongs to the door. Click/Tap on the Door and head on out of here!"
wait(3)
MoveLock.Value = false
Sound:Stop()
Screen.Enabled = false
-- Un comment out if you want sound
Screen.Enabled = false-- Disable Screen Gui
MoveLock.Value = false
end)
Second Script: Where error pops up
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PartTouchRemote = ReplicatedStorage.PartTouch
local Loren = game.Workspace.Loren
if Loren then
local initialPosition = Loren:GetPivot()
Players.PlayerAdded:Connect(function(player)
PartTouchRemote.OnServerEvent(Players) -- Line where the error pops up
if Loren then
-- Teleport and rotate Loren
Loren:PivotTo(CFrame.new(-20.868, 0, -50.126) * CFrame.Angles(0, math.rad(-90), 0))
end
end)
Players.PlayerRemoving:Connect(function(player)
if Loren then
Loren:PivotTo(initialPosition)
print("Loren Returned")
end
end)
end
Third Script: Where error pops up
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PartTouchRemote = ReplicatedStorage.PartTouch
local Players = game:GetService("Players")
PartTouchRemote.OnServerEvent(Players) -- line where error pops up
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local mannequin = script.Parent
local humanoid = mannequin:FindFirstChildOfClass("Humanoid")
local rootPart = mannequin:FindFirstChild("HumanoidRootPart")
local FOLLOW_DISTANCE = 100 -- Distance threshold for following the player
local function isPlayerLookingAtMannequin(player)
local character = player.Character
if not character then return false end
local head = character:FindFirstChild("Head")
if not head then return false end
local lookVector = head.CFrame.LookVector
local directionToMannequin = (rootPart.Position - head.Position).unit
local dotProduct = lookVector:Dot(directionToMannequin)
return dotProduct > 0 -- Adjust this threshold as needed
end
local function onPlayerTouched(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
local playerHumanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if playerHumanoid then
playerHumanoid.Health = 0
end
end
end
local function followPlayer()
local closestPlayer = nil
local closestDistance = math.huge
for _, player in Players:GetPlayers() do
local character = player.Character
if character then
local distance = (character.PrimaryPart.Position - rootPart.Position).magnitude
if distance < closestDistance then
closestDistance = distance
closestPlayer = player
end
end
end
if closestPlayer and closestDistance <= FOLLOW_DISTANCE and not isPlayerLookingAtMannequin(closestPlayer) then
local targetPosition = closestPlayer.Character.PrimaryPart.Position
local direction = (targetPosition - rootPart.Position).unit
rootPart.CFrame = CFrame.new(rootPart.Position, rootPart.Position + direction)
humanoid:MoveTo(targetPosition)
else
humanoid:MoveTo(rootPart.Position) -- Stop moving if player is looking or too far
end
end
rootPart.Touched:Connect(onPlayerTouched)
RunService.Heartbeat:Connect(followPlayer)