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

Simple TeamChange script not working, help please?

Asked by 9 years ago

I don't know why this isn't working. I made GroupID and GroupRank and TrainerTeam in ServerScriptService>HostService but I don't know what's wrong.

This is a Local Script.

local Player = game.Players.LocalPlayer
local SSS = game:GetService("ServerScriptService")
local HS = SSS:WaitForChild("HostService")
local GroupID = HS:WaitForChild("GroupID").Value
local GroupRank = HS:WaitForChild("GroupRank").Value
local TrainerTeamColor = HS:WaitForChild("TrainerTeam").Value

script.Parent.MouseButton1Down:connect(function()
    if Player:GetRankInGroup(GroupID) >= GroupRank then
        Player.TeamColor = TrainerTeamColor
        Player.Character:BreakJoints()
    end
end)

Screenshot

^That's the output. Apparently it's not getting HostService. But I made sure I named the Folder right and I put the right name in the script. I don't get what's happening.

1 answer

Log in to vote
1
Answered by 9 years ago

The main reason is because you're using a localscript with ServerScriptService.

ServerScriptService DOES NOT replicate to clients.

As per the Wiki's definition of ServerScriptService:

A semantic, organized place to put your server-sided game logic, which does not interfere with the world. Scripts will run inside this service, and will not replicate to game clients, allowing for secure storage of your scripts.

If you moved all your things to Replicated Storage and changed line 2 to

local SSS = game:GetService("ReplicatedStorage")

The above would work due to the fact that since you're using a localscript, the objects MUST be replicated to clients.

Source:

http://wiki.roblox.com/index.php?title=API:Class/ServerScriptService

0
Actually, it was just ROBLOX messing up like usual. I have other scripts that work like this, it was just a problem of finding "HostService" in that one script. TypicalModerator 110 — 9y
Ad

Answer this question