Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script thinks RoundObj is Local Player and text not showing?

Asked by 6 years ago
Edited 6 years ago

Hello, as you can see in the title, I noticed that when I fire the server, I made an if statement that checks what the name of the object is. I noticed that the script returns my username. I have checked the function but it shows me variant arguments. I have passed an argument in the event. I also checked OnServerEvent and it returns a player argument and tuple variant arguments I have tried two arguments however, it didn't work.

Here is the script in ServerScriptService

math.randomseed(tick())
local mapFolder = game:GetService("ServerStorage"):WaitForChild("Maps")
local event = game:GetService("ReplicatedStorage"):WaitForChild("GameEvent")
local playerAmount = workspace:WaitForChild("PlayerCount").Value
local maps = {
    mapFolder:WaitForChild("Map1"),
    mapFolder:WaitForChild("Map2"),
    mapFolder:WaitForChild("Map3")
} 
event.OnServerEvent:Connect(function(roundObj)
    if roundObj then print(roundObj.Name) else print("RoundObj nil") end
    if playerAmount >= 3 then
        for countdown = 10,0,-1 do
            roundObj = "Game starting in " .. countdown .. " seconds!"
            wait(1)     
        end     
        local map = maps[math.random(1,#maps)]:Clone()
        if map.Name == "Map1" then
            roundObj = "Map chosen: Flood Escape "
        end 
        if map.Name == "Map2" then
            roundObj = "Map chosen: something"
        end
        if map.Name == "Map3" then
            roundObj = "Map chosen: idk"
        end  
        roundObj = map.Name .. " has been chosen"   
        map.Parent = workspace
    else
        roundObj = "You need ".. 3 - playerAmount .. " players to start a game"
    end 
end)

Here is the local script in StarterGui

local event = game:GetService("ReplicatedStorage"):WaitForChild("GameEvent")
local player = game.Players.LocalPlayer
local playerUI = player:WaitForChild("PlayerGui")
local intermission = playerUI:WaitForChild("IntermissionGui"):WaitForChild("IntermissionTxt").Text
event:FireServer(intermission)

1 answer

Log in to vote
1
Answered by 6 years ago

The OnServerEvent of a RemoteEvent automatically puts the LocalPlayer into the first parameter.

RBXScriptSignal OnServerEvent ( Player player, Tuple<Variant> arguments )

0
Then I would have to do like event.OnServerEvent:Connect(function(player, roundObj)? saSlol2436 716 — 6y
0
Plus I have done the FireServer in a LocalScript, and it has local player, event:FireServer(player,intermission)? saSlol2436 716 — 6y
0
You don't need to use FireServer with the player, it automatically puts the player in the first parameter LegitimatlyMe 519 — 6y
Ad

Answer this question