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

Client > ServerEvent Issues?

Server

game.ReplicatedStorage.StatusChange.OnServerEvent:Connect(function(StatusText)
	game.Lighting.Status.Time.Text = StatusText
	local sound = Instance.new("Sound",game.Workspace)
	sound.Name = "StatusChangedSound"
	sound.SoundId = "rbxassetid://".."138093550"
	sound.Looped = true
	local pitcher = Instance.new("PitchShiftSoundEffect",sound)
	pitcher.Octave = 0.815
	sound:Play()
	wait(2)
	sound:Destroy()
end)

Local

script.Parent.MouseButton1Click:Connect(function()
	local StatusText = "Lunch"
	game.ReplicatedStorage.StatusChange:FireServer(StatusText)
end)

Keeps saying "String Expected, Got Object"

1 comment

0

The OnServerEvent automatically has a Player object parameter as it's first argument without you having to pass it in. On Line 1 of the server script do ...:Connect(function(player, StatusText)

1 answer

Put .Name at line 2 of the serverscript, so the script ends up looking like this:

game.ReplicatedStorage.StatusChange.OnServerEvent:Connect(function(StatusText)
	game.Lighting.Status.Time.Text = StatusText.Name
    local sound = Instance.new("Sound",game.Workspace)
     print(StatusText)
    sound.Name = "StatusChangedSound"
    sound.SoundId = "rbxassetid://".."138093550"
    sound.Looped = true
    local pitcher = Instance.new("PitchShiftSoundEffect",sound)
    pitcher.Octave = 0.815
    sound:Play()
    wait(2)
    sound:Destroy()
end)

Player is an object value, and the script was expecting the .Name string. Please be sure to accept the answer if you felt this helped.

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