So I've been trying to make this shouting simulator game with a friend of mine and we both seem stumped (yet again) with this error. Note that this script is a server script and not a local or module
These are the pieces of code in question;
local function shout(points,shout,plr) addPoints(points,plr) local chr = plr.Character local sound = chr:WaitForChild("Head"):WaitForChild("Shout") sound.SoundId = shout sound:Play() end
rs.Events.Shouted.Event:Connect(function(points,shout,plr) print(points) print(shout) print(plr) shout(points,shout,plr) -- This line is where the error comes from end)
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(chr) local shoutSound = Instance.new("Sound") shoutSound.Name = "Shout" shoutSound.Parent = chr:WaitForChild("Head") end) end)
It says the error is on line 40 of the code (which I have specified in the code blocks) and I'm not sure where it's coming from.
Change your code to the following....
local function shout(points,shoutID,plr) addPoints(points,plr) local chr = plr.Character local sound = chr:WaitForChild("Head"):WaitForChild("Shout") sound.SoundId = shoutID sound:Play() end -- ....... rs.Events.Shouted.Event:Connect(function(points,myshout,plr) -- this was the real place where the type mismatch was occurring since you was using the same namespace as the function shout()! print(points) print(myshout) print(plr) shout(points,myshout,plr) -- This line is where the error comes from end)
Explain: You've declared a function named shout, but then you use a variable named exactly the same.
The error you're getting is exactly what it says, "trying to call a string value" aka your string you declared in your shouted event. Lua thinks you're trying to call that string as if it's a function, but we know it's not. It's just a string!