Hey there, I am new to this field of scripting. It’s been untouched for me because for a while now I’ve dreaded having to deal with the problems that it brings up within my understanding. I have already extensively done a lot of GUI scripting a while now, that’s my comfortable spot with scripting, but I wanted to go out of my way and add another mechanic to one of the games I’m developing that require remote events to be possible.
I’m wanting to make an event in where when the player presses the shift key, a part is put at the position of the torso that is a bubble, a lot like the one in the Smash Bros’ games, as a shield. The bubble has not been added yet because I am having issues with the basic functionality of the event firing correctly with a simple string, which errors as down below.
ServerScriptService.BubbleServer:4: Expected identifier when parsing variable name, got 'true'
“True” and “False” in the server script are underlined red.
I have looked up tons of tutorials and documentation already on how to do this, so I am pretty well informed and already spent a few hours trying to find the problem.
The way I want to do this is to have two arguments for two different fire events; one true, one false. The true event will fire when the shift key is pressed down, the false event will trigger when the shift key is released. For both events, for now, I want them to print the player’s name and true or false to verify it works-- in which case right now does not work.
It’s probably a very simple and silly mistake, but it’s all a part of scripting. Hope somebody can help me out.
The remote event itself is located under ReplicatedStorage.Remotes, and is called BubbleHandler.
The local script is under StarterGui.
The server script is under ServerScriptService.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteBubble = ReplicatedStorage.Remotes.BubbleHandler local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(input) -- Input Began checks if the player presses anything and fires whenever the player does so. if input.KeyCode == Enum.KeyCode.LeftShift then -- This detects for a "left shift" press. print("[Bubble Start] Client Fired!") remoteBubble:FireServer(true) end end) UserInputService.InputEnded:Connect(function(input) -- Fires when input ended print("[Bubble End] Client Fired!") remoteBubble:FireServer(false) end)
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteBubble = ReplicatedStorage.Remotes.BubbleHandler remoteBubble.OnServerEvent:Connect(function(player, true) print (player.name.." had fired the event. true") end) remoteBubble.OnServerEvent:Connect(function(player, false) print (player.name.." had fired the event. false") end)