Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why the RemoteEvent is only woking in-Studio but not in-Game?

i made 2 scripts connected to each other using RemoteEvent to give player a uniform if he answer with "Yes" (Dialog)

But.. its only working if i tested in-studio, and its not working in-game.

the First located in the NPC

local debounce = true
local UniEvent = game.ReplicatedStorage:WaitForChild("UniformGiveEvent")

script.Parent.DialogChoiceSelected:connect(function(player, choice)
	if choice == script.Parent.Yes then
		if debounce then
			debounce = false
			UniEvent:FireServer()
		end
	end
end)

and the Second located in the ServerScriptService

local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "UniformGiveEvent"
local Shirt = "rbxassetid://000000000" -- Random code
local Pants = "rbxassetid://000000000" -- Random code

function GiveUni(plr)
	local character = plr.Character
	local shirt = character.Shirt
	local pants = character.Pants
	shirt.ShirtTemplate = Shirt
	pants.PantsTemplate = Pants
end

Event.OnServerEvent:Connect(GiveUni)

Please Help Me!

3 comments

0

were there any errors in game on the devloper tab?

0

Why don't you just make the event yourself instead of having the script do it? Also are your scripts local or server?

0

I love using a Wok to cook with.

1 answer

###It "works" in studio because you used Play Solo mode. Play Solo is the server and client combined, they are one. There is no separation between the two, so this is why local scripts may have access to things they shouldn't have access to, such as the ServerStorage service. Use local servers to test scripts instead.

Anyway, since DialogChoiceSelected is server-sided, you don't need any RemoteEvents. The uniform giving script can also error if a player doesn't have a shirt or pants.

local Shirt = "rbxassetid://000000000" -- Random code
local Pants = "rbxassetid://000000000" -- Random code
local debounce = true

local function GiveUni(plr, choice)
    if choice == script.Parent.Yes then
        if debounce then
            debounce = false 
            local character = plr.Character
            local shirt = character:FindFirstChild("Shirt") or Instance.new("Shirt")
            local pants = character:FindFirstChild("Pants") or Instance.new("Pants")
            shirt.ShirtTemplate = Shirt
            pants.PantsTemplate = Pants
            shirt.Parent = character
            pants.Parent = character
        end
    end
end

script.Parent.DialogChoiceSelected:Connect(GiveUni)

2 comments

0

nope :( its not working tho

0

now its not even working in-studio :I

This discussion is preserved as it was. New answers, comments, and votes are closed.