I’ve been working on a JTOH-esque game with some friends as a passion project, and currently, I have hit a roadblock with the message system, and I haven’t been able to figure it out. The script is supposed to display a server message telling that a player has completed a tower (obstacle course) with a time, and tower name. It replicates correctly on the client, and will not display a message if the player touches a winpad not associated with the tower they are currently doing.
However, this is not replicating properly to the server, and I have not figured a workaround for it. The total time is not being replicated properly, and if the player touches the incorrect winpad, a message will still show up to the server. I know it has to do something with the fact that it is a localscript, but scripting is definitely not my strong suit, so that is why I am asking to help:
- Properly replicate the time on the server
- Properly replicate false wins on the server
- Some sort of method to grab a player’s local value from a server script
MessageScript (displays server messages)
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local StarterGUI = game:GetService('StarterGui')
local timeresult = game.StarterGui.TimerGUI.Frame.Timer
local remoteEvent = ReplicatedStorage:WaitForChild('WinpadEvent')
local debounce = false
local Player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
-- textColor = BrickColor.new('Lime green')
local function win(playerName, towerName, difficulty, towercertifcation)
if debounce == false then
debounce = true
local towertime = Player.PlayerGui.TimerGUI.Frame.Timer.Text
local towervalue = Player.CurrentTower.Value
print(towertime)
if towervalue == towercertifcation then
game.StarterGui:SetCore('ChatMakeSystemMessage', {
Text = '[SERVER]: '..playerName..' has beaten '..towerName.. ' in ' .. towertime..'!';
Font = Enum.Font.SourceSansBold;
Color = difficulty;
FontSize = Enum.FontSize.Size24;
})
wait(1)
debounce = false
elseif playerName ~= game.Players.LocalPlayer.Name then
game.StarterGui:SetCore('ChatMakeSystemMessage', {
Text = '[SERVER]: '..playerName..' has beaten '..towerName.. ' in ' .. towertime..'!';
Font = Enum.Font.SourceSansBold;
Color = difficulty;
FontSize = Enum.FontSize.Size24;
})
wait(1)
debounce = false
else
wait(1)
debounce = false
end
end
end
remoteEvent.OnClientEvent:Connect(win)
WinScript (found in each winpad, sends an event to the messagescript)
local telepoint = Vector3.new(-91.934, 164.76, -346.019)
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('WinpadEvent')
local TowerName = script.Parent.Parent
local Difficulty = script.Parent:WaitForChild("Difficulty")
local teams = game:GetService("Teams")
local Cert = script.Parent:WaitForChild('TowerCertification')
local function onPartTouch(otherPart)
local debounce = false
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if humanoid then
if debounce == false then
debounce = true
humanoid.Parent.Torso.CFrame = CFrame.new(telepoint + Vector3.new(0,3,0))
player.Team = teams.Winners
remoteEvent:FireAllClients(humanoid.DisplayName, TowerName.Name, Difficulty.Value, Cert.Value)
end
end
end
script.Parent.Touched:Connect(onPartTouch)
![]()
![]()